svelte-effect-runtime 4.0.1 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dist/chunks/{client-BrZka6DW.js → client-DbwVAMWm.js} +5 -5
- package/.dist/chunks/{client-BrZka6DW.js.map → client-DbwVAMWm.js.map} +1 -1
- package/.dist/chunks/{compiler-COVzgLYo.js → compiler-Dpyu4Owd.js} +2 -2
- package/.dist/chunks/{compiler-COVzgLYo.js.map → compiler-Dpyu4Owd.js.map} +1 -1
- package/.dist/chunks/{descriptors-B4otDlm1.js → descriptors-q909VWyR.js} +3 -3
- package/.dist/chunks/{descriptors-B4otDlm1.js.map → descriptors-q909VWyR.js.map} +1 -1
- package/.dist/chunks/{diagnostics-BDrky-Di.js → diagnostics-DLwwrBWb.js} +2 -2
- package/.dist/chunks/{diagnostics-BDrky-Di.js.map → diagnostics-DLwwrBWb.js.map} +1 -1
- package/.dist/chunks/{dispatcher-_x0MQZBS.js → dispatcher-CTWINW5I.js} +219 -16
- package/.dist/chunks/dispatcher-CTWINW5I.js.map +1 -0
- package/.dist/chunks/dispatcher-pZPzarul.js +23 -0
- package/.dist/chunks/dispatcher-pZPzarul.js.map +1 -0
- package/.dist/chunks/{errors-CLsbGjIa.js → errors-qhcbUH6o.js} +19 -2
- package/.dist/chunks/{errors-CLsbGjIa.js.map → errors-qhcbUH6o.js.map} +1 -1
- package/.dist/chunks/{live-BundLSoY.js → live-BW7xZKjb.js} +2 -2
- package/.dist/chunks/{live-BundLSoY.js.map → live-BW7xZKjb.js.map} +1 -1
- package/.dist/chunks/{runtime-HDTlEnzp.js → runtime-CPosEhGl.js} +3 -3
- package/.dist/chunks/{runtime-HDTlEnzp.js.map → runtime-CPosEhGl.js.map} +1 -1
- package/.dist/chunks/{server-BNrA1I-u.js → server-yQrNoiCR.js} +2 -2
- package/.dist/chunks/{server-BNrA1I-u.js.map → server-yQrNoiCR.js.map} +1 -1
- package/.dist/chunks/{source-scan-9pZxnfct.js → source-scan-cSawCvsg.js} +2 -2
- package/.dist/chunks/source-scan-cSawCvsg.js.map +1 -0
- package/.dist/chunks/{transform-BXyYUAez.js → transform-D7TTlPpK.js} +75 -27
- package/.dist/chunks/transform-D7TTlPpK.js.map +1 -0
- package/.dist/compiler.js +1 -1
- package/.dist/dispatcher/index.d.ts +49 -0
- package/.dist/dispatcher/scope.d.ts +36 -0
- package/.dist/dispatcher.d.ts +2 -1
- package/.dist/dispatcher.js +2 -2
- package/.dist/errors.d.ts +14 -0
- package/.dist/generated/dispatcher.d.ts +6 -1
- package/.dist/generators.d.ts +1 -0
- package/.dist/internal/generators.js +4 -4
- package/.dist/internal/remote-client.js +1 -1
- package/.dist/internal/remote-server.js +1 -1
- package/.dist/markup/promise.js +1 -1
- package/.dist/markup/run.js +1 -1
- package/.dist/markup/transform/apply.d.ts +4 -3
- package/.dist/markup/transform/constants.d.ts +1 -0
- package/.dist/markup/transform/types.d.ts +16 -0
- package/.dist/markup/transform.js +1 -1
- package/.dist/markup/value.js +1 -1
- package/.dist/mod.d.ts +1 -1
- package/.dist/mod.js +5 -5
- package/.dist/mod.js.map +1 -1
- package/.dist/remote/client.js +1 -1
- package/.dist/remote/server.js +1 -1
- package/.dist/runtime/transform.js +26 -12
- package/.dist/runtime/transform.js.map +1 -1
- package/.dist/script-transform/imports.d.ts +3 -1
- package/.dist/script-transform/index.d.ts +2 -0
- package/.dist/script-transform/types.d.ts +8 -0
- package/.dist/server.js +5 -5
- package/package.json +2 -2
- package/.dist/chunks/dispatcher-BA0PLQhA.js +0 -16
- package/.dist/chunks/dispatcher-BA0PLQhA.js.map +0 -1
- package/.dist/chunks/dispatcher-_x0MQZBS.js.map +0 -1
- package/.dist/chunks/source-scan-9pZxnfct.js.map +0 -1
- package/.dist/chunks/transform-BXyYUAez.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatcher-CTWINW5I.js","names":["#on_dispose","#scope","#disposed","#notify_value_cells","#runtime","#root_scope","#component_scopes","#current_scope","#disposed","#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","#clear_pending_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","#scope_ids","#next_scope_id","#is_current_fiber","#set_value_cell","#complete_fiber","#publish_value_success","#publish_value_failure","#delete_value_cell","#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/** 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 component scope and starts it. The fiber becomes\n\t * a child of the scope, so disposing the scope interrupts it and runs its\n\t * finalizers. Returns an idempotent handle that interrupts the scoped\n\t * fiber directly.\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\t/**\n\t\t * Track the scoped fiber itself: `forkIn` binds it to the component\n\t\t * scope rather than the awaiting parent, so per-run disposal must\n\t\t * interrupt the scoped fiber directly.\n\t\t */\n\t\tlet scoped_fiber: FiberType<unknown, unknown> | undefined;\n\n\t\tthis.#runtime.runFork(\n\t\t\tEffect.flatMap(scope.fork_in(effect), (fiber) => {\n\t\t\t\tscoped_fiber = fiber;\n\n\t\t\t\treturn Effect.asVoid(Fiber.await(fiber));\n\t\t\t}) as Effect.Effect<unknown, unknown, unknown>,\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\n\t\t\tif (scoped_fiber) {\n\t\t\t\tthis.#runtime.runFork(InterruptFiber(scoped_fiber));\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\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\tconst old_fiber = this.#interrupt_cached_fiber(old_key);\n\n\t\t\tthis.#clear_pending_value_cell(old_key, old_fiber);\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 Program = 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\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\tconst scope = this.#current_scope;\n\n\t\treturn this.#runtime.runPromise(\n\t\t\t(scope\n\t\t\t\t? Effect.provideService(Program, Scope.Scope, scope.underlying)\n\t\t\t\t: Program) as Effect.Effect<A, unknown, unknown>,\n\t\t);\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#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#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\t/**\n\t\t * Provide the active component scope so scoped acquisition works and\n\t\t * finalizers run when the scope closes on unmount. Interruption of an\n\t\t * individual run does not close the component scope; its finalizers\n\t\t * run at scope disposal, matching the component lifetime.\n\t\t */\n\t\tconst scope = this.#current_scope;\n\t\tconst ScopedProgram = scope\n\t\t\t? Effect.provideService(Program, Scope.Scope, scope.underlying)\n\t\t\t: Program;\n\t\tconst fiber = this.#runtime.runFork(ScopedProgram as Effect.Effect<unknown, unknown, unknown>);\n\n\t\tthis.#fibers.set(cache_key, fiber);\n\n\t\tqueueMicrotask(() => {\n\t\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (this.#value_cells.has(cache_key)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.#set_value_cell(cache_key, {\n\t\t\t\tstatus: \"pending\",\n\t\t\t\tfiber,\n\t\t\t});\n\t\t});\n\n\t\tthis.#runtime.runFork(\n\t\t\tWatchFiberExit({\n\t\t\t\tfiber,\n\t\t\t\tsurface_failure: false,\n\t\t\t\ton_complete: () => this.#complete_fiber(cache_key, fiber),\n\t\t\t\ton_success: (value) => this.#publish_value_success(cache_key, fiber, value),\n\t\t\t\ton_failure: (error) => this.#publish_value_failure(cache_key, fiber, error),\n\t\t\t}),\n\t\t);\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\t/**\n\t\t * See #start_value_fiber: the component scope is provided ambiently so\n\t\t * scoped acquisition works and finalizers run on unmount.\n\t\t */\n\t\tconst scope = this.#current_scope;\n\t\tconst ScopedProgram = scope\n\t\t\t? Effect.provideService(Program, Scope.Scope, scope.underlying)\n\t\t\t: Program;\n\t\tconst fiber = this.#runtime.runFork(ScopedProgram as Effect.Effect<unknown, unknown, unknown>);\n\t\tconst ReleaseFiber = Effect.sync(() => {\n\t\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.#fibers.delete(cache_key);\n\t\t\tthis.#promise_values.delete(cache_key);\n\n\t\t\tif (this.#promise_ids.get(cache_id) === cache_key) {\n\t\t\t\tthis.#promise_ids.delete(cache_id);\n\t\t\t}\n\t\t});\n\t\tconst AwaitFiber = Effect.gen(function* () {\n\t\t\tconst exit = yield* Fiber.await(fiber);\n\n\t\t\tyield* ReleaseFiber;\n\n\t\t\tif (Exit.isSuccess(exit)) {\n\t\t\t\treturn exit.value as A;\n\t\t\t}\n\n\t\t\treturn yield* Effect.fail(Cause.squash(exit.cause));\n\t\t});\n\n\t\tthis.#fibers.set(cache_key, fiber);\n\n\t\treturn this.#runtime.runPromise(AwaitFiber);\n\t}\n\n\t#clear_pending_value_cell(\n\t\tcache_key: string,\n\t\tfiber: FiberType<unknown, unknown> | undefined,\n\t): void {\n\t\tconst cell = this.#value_cells.get(cache_key);\n\n\t\tif (cell?.status !== \"pending\") {\n\t\t\treturn;\n\t\t}\n\n\t\tif (fiber !== undefined && cell.fiber !== fiber) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#delete_value_cell(cache_key);\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\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\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\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,MAAM,EAAE,OAAO,aAAa,YAAY,YAAY,kBAAkB,SAAS;CAE/E,OAAO,OAAO,IAAI,aAAa;EAC9B,MAAM,OAAO,OAAO,MAAM,MAAM,KAAK;EAErC,OAAO,OAAO,WAAW;GACxB,IAAI,KAAK,UAAU,IAAI,GAAG;IACzB,aAAa,KAAK,KAAU;IAC5B,cAAc;IAEd;GACD;GAEA,IAAI,CAAC,MAAM,kBAAkB,KAAK,KAAK,GAAG;IACzC,MAAM,QAAQ,MAAM,OAAO,KAAK,KAAK;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her-CTWINW5I.js";
|
|
2
|
+
import { r as get_server_dispatcher } from "./runtime-CPosEhGl.js";
|
|
3
|
+
//#region src/generated/dispatcher.ts
|
|
4
|
+
var Dispatcher = class {
|
|
5
|
+
static emit(event) {
|
|
6
|
+
return get_dispatcher().emit(event);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Runs `fn` with `scope` as the active component scope so emitted work is
|
|
10
|
+
* bound to the calling component's lifetime.
|
|
11
|
+
*/
|
|
12
|
+
static with_scope(scope, fn) {
|
|
13
|
+
return get_dispatcher().with_scope(scope, fn);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
function get_dispatcher() {
|
|
17
|
+
if (typeof document === "undefined") return get_server_dispatcher();
|
|
18
|
+
return get_dispatcher$1();
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { get_dispatcher as n, Dispatcher as t };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=dispatcher-pZPzarul.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatcher-pZPzarul.js","names":["get_client_dispatcher"],"sources":["../../../modules/svelte-effect-runtime/src/generated/dispatcher.ts"],"sourcesContent":["import type {\n\tComponentScope,\n\tDispatcher as RuntimeDispatcher,\n\tDispatcherEvent,\n\tMarkupPromiseEvent,\n\tMarkupRunEvent,\n\tMarkupValueEvent,\n} from \"$/dispatcher.ts\";\nimport { get_dispatcher as get_client_dispatcher } from \"$/dispatcher.ts\";\nimport { get_server_dispatcher } from \"$/server/runtime.ts\";\n\nexport { Code } from \"$/dispatcher.ts\";\nexport type {\n\tDispatcherEvent,\n\tMarkupPromiseEvent,\n\tMarkupPromiseOptions,\n\tMarkupRunEvent,\n\tMarkupValueEvent,\n} from \"$/dispatcher.ts\";\n\nexport class Dispatcher {\n\tstatic emit<A, F>(event: MarkupValueEvent<A, F>): A | F;\n\tstatic emit<A>(event: MarkupPromiseEvent<A>): Promise<A>;\n\tstatic emit<A>(event: MarkupRunEvent<A>): Promise<A>;\n\tstatic emit<A, F>(event: DispatcherEvent<A, F>): A | F | Promise<A>;\n\tstatic emit<A, F>(event: DispatcherEvent<A, F>): A | F | Promise<A> {\n\t\treturn get_dispatcher().emit(event);\n\t}\n\n\t/**\n\t * Runs `fn` with `scope` as the active component scope so emitted work is\n\t * bound to the calling component's lifetime.\n\t */\n\tstatic with_scope<T>(scope: ComponentScope, fn: () => T): T {\n\t\treturn get_dispatcher().with_scope(scope, fn);\n\t}\n}\n\nexport function get_dispatcher(): RuntimeDispatcher {\n\tif (typeof document === \"undefined\") {\n\t\treturn get_server_dispatcher();\n\t}\n\n\treturn get_client_dispatcher();\n}\n"],"mappings":";;;AAoBA,IAAa,aAAb,MAAwB;CAKvB,OAAO,KAAW,OAAkD;EACnE,OAAO,eAAe,CAAC,CAAC,KAAK,KAAK;CACnC;;;;;CAMA,OAAO,WAAc,OAAuB,IAAgB;EAC3D,OAAO,eAAe,CAAC,CAAC,WAAW,OAAO,EAAE;CAC7C;AACD;AAEA,SAAgB,iBAAoC;CACnD,IAAI,OAAO,aAAa,aACvB,OAAO,sBAAsB;CAG9B,OAAOA,iBAAsB;AAC9B"}
|
|
@@ -430,6 +430,23 @@ var DispatcherDisposedError = class extends RuntimeError {
|
|
|
430
430
|
}
|
|
431
431
|
};
|
|
432
432
|
/**
|
|
433
|
+
* Thrown when Effect work is bound to a component scope that has already been
|
|
434
|
+
* disposed.
|
|
435
|
+
*
|
|
436
|
+
* @example
|
|
437
|
+
* ```ts
|
|
438
|
+
* throw new ScopeDisposedError();
|
|
439
|
+
* ```
|
|
440
|
+
*
|
|
441
|
+
* @since 3.1.0
|
|
442
|
+
*/
|
|
443
|
+
var ScopeDisposedError = class extends RuntimeError {
|
|
444
|
+
constructor() {
|
|
445
|
+
super("Effect scope has been disposed; no new Effect work can be bound to a destroyed component's scope.");
|
|
446
|
+
this.name = "ScopeDisposedError";
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
/**
|
|
433
450
|
* Thrown when an application attempts to configure a runtime after one has
|
|
434
451
|
* already been initialized.
|
|
435
452
|
*
|
|
@@ -694,6 +711,6 @@ var RemoteHelperError = class extends RuntimeError {
|
|
|
694
711
|
}
|
|
695
712
|
};
|
|
696
713
|
//#endregion
|
|
697
|
-
export {
|
|
714
|
+
export { UnsupportedMarkupEffectPositionError as A, ServerOnlyImportError as C, UncheckedLiveQueryHandlerMissingError as D, UncheckedFormHandlerMissingError as E, YieldStarInEventCallbackError as M, UncheckedPrerenderHandlerMissingError as O, ScopeDisposedError as S, UncheckedCommandHandlerMissingError as T, RemoteHelperContextError as _, DispatcherDisposedError as a, RuntimeAlreadyInitializedError as b, InvalidLiveQueryFactoryError as c, InvalidQueryFactoryError as d, InvalidRemoteFormResponseError as f, RemoteFormEndpointMissingError as g, RemoteErrorDecodeError as h, BatchQueryHandlerMissingError as i, UnsupportedRemoteFormResponseError as j, UncheckedQueryHandlerMissingError as k, InvalidLiveQueryReturnError as l, PreprocessError as m, AsyncEffectInSyncRuneError as n, EmptyStreamYieldError as o, InvalidYieldableError as p, AwaitInEffectWorkError as r, InvalidCommandFactoryError as s, AsyncEffectInEventCallbackError as t, InvalidPrerenderFactoryError as u, RemoteHelperError as v, SvelteKitServerExportUnavailableError as w, RuntimeError as x, RequestEventUnavailableError as y };
|
|
698
715
|
|
|
699
|
-
//# sourceMappingURL=errors-
|
|
716
|
+
//# sourceMappingURL=errors-qhcbUH6o.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors-CLsbGjIa.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/errors.ts"],"sourcesContent":["/**\n * Base class for runtime-authored errors. The class gives every local failure\n * a stable JavaScript error name while preserving the technical message that\n * reaches Vite, SvelteKit, and test output.\n *\n * @example\n * ```ts\n * throw new RuntimeError(\"Invariant violated.\");\n * ```\n *\n * @since 2.4.0\n * @param message - Technical diagnostic message describing the failed runtime\n * invariant.\n */\nexport class RuntimeError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"RuntimeError\";\n\t}\n}\n\nexport function make_error_message(code: string, message: string): string {\n\treturn `[${code}]: ${message}`;\n}\n\n/**\n * Base error class for all preprocessor errors emitted during script and\n * markup transformation. Carries the source filename so error messages can\n * reference the affected file.\n *\n * @example\n * ```ts\n * throw new PreprocessError(\"Component.svelte: invalid transform input.\", \"Component.svelte\");\n * ```\n *\n * @since 2.0.0\n * @param message - Technical diagnostic message for the transform failure.\n * @param filename - Source filename that triggered the transform failure.\n */\nexport class PreprocessError extends RuntimeError {\n\t/**\n\t * The source filename that triggered this error.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly filename: string;\n\n\tconstructor(message: string, filename: string) {\n\t\tsuper(message);\n\t\tthis.name = \"PreprocessError\";\n\t\tthis.filename = filename;\n\t}\n}\n\n/**\n * Thrown when a statement mixes JavaScript `await` with Effect `yield*` work\n * that must be lowered into an `Effect.gen` program.\n *\n * @example\n * ```ts\n * throw new AwaitInEffectWorkError(\"Component.svelte\", \"const value = await load();\");\n * ```\n *\n * @since 2.0.0\n * @param filename - Source filename containing the unsupported statement.\n * @param statement_text - Full source text for the statement containing\n * mixed async work.\n */\nexport class AwaitInEffectWorkError extends PreprocessError {\n\t/**\n\t * The full text of the problematic statement containing mixed async work.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly statement_text: string;\n\n\tconstructor(filename: string, statement_text: string) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\tmake_error_message(\n\t\t\t\t\t\"AWAIT_IN_EFFECT_WORK\",\n\t\t\t\t\t`${filename}: await cannot be mixed with yield* in Effect work.`,\n\t\t\t\t),\n\t\t\t\t`Top-level await is supported as ordinary Svelte async rendering, but statements lowered into Effect.gen must use yield* for async Effect work.`,\n\t\t\t\t\"\",\n\t\t\t\t`Problematic statement:`,\n\t\t\t\tstatement_text,\n\t\t\t].join(\"\\n\"),\n\t\t\tfilename,\n\t\t);\n\t\tthis.name = \"AwaitInEffectWorkError\";\n\t\tthis.statement_text = statement_text;\n\t}\n}\n\n/**\n * Thrown when async Effect work appears inside a Svelte rune position that\n * must stay synchronous.\n *\n * @example\n * ```ts\n * throw new AsyncEffectInSyncRuneError(\"$derived\", \"$derived(yield* load())\", \"Component.svelte\");\n * ```\n *\n * @since 2.0.0\n * @param rune_name - Name of the Svelte rune containing the unsupported async\n * Effect work.\n * @param expression_text - Full source text for the rune expression.\n * @param filename - Source filename containing the unsupported rune.\n */\nexport class AsyncEffectInSyncRuneError extends PreprocessError {\n\t/**\n\t * The name of the rune that contained async Effect work.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly rune_name: string;\n\n\t/**\n\t * The full text of the expression that triggered the error.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly expression_text: string;\n\n\tconstructor(rune_name: string, expression_text: string, filename: string) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\tmake_error_message(\n\t\t\t\t\t\"ASYNC_EFFECT_IN_SYNC_RUNE\",\n\t\t\t\t\t`${filename}: yield* cannot be used inside ${rune_name}().`,\n\t\t\t\t),\n\t\t\t\t`${rune_name}() must stay synchronous. Do not put async Effect work inside this rune.`,\n\t\t\t\t\"\",\n\t\t\t\t`Problematic expression:`,\n\t\t\t\texpression_text,\n\t\t\t].join(\"\\n\"),\n\t\t\tfilename,\n\t\t);\n\t\tthis.name = \"AsyncEffectInSyncRuneError\";\n\t\tthis.rune_name = rune_name;\n\t\tthis.expression_text = expression_text;\n\t}\n}\n\n/**\n * Thrown when async Effect work appears inside a non-generator callback nested\n * in a markup event handler.\n *\n * @example\n * ```ts\n * throw new AsyncEffectInEventCallbackError(\n * \"Component.svelte\",\n * \"Effect.try(() => yield* save())\",\n * );\n * ```\n *\n * @since 2.0.0\n * @param filename - Source filename containing the invalid event handler.\n * @param expression_text - Event handler expression that contains the nested\n * unsupported async Effect work.\n */\nexport class AsyncEffectInEventCallbackError extends PreprocessError {\n\t/**\n\t * The full text of the problematic event handler body.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly expression_text: string;\n\n\tconstructor(filename: string, expression_text: string) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\tmake_error_message(\n\t\t\t\t\t\"ASYNC_EFFECT_IN_EVENT_CALLBACK\",\n\t\t\t\t\t`${filename}: yield* cannot be used inside a nested non-generator callback in a markup event handler.`,\n\t\t\t\t),\n\t\t\t\t`Move the yield* to the event handler body. Effect.try and Effect.sync callbacks are plain synchronous JavaScript; do not call Effect-returning functions inside them.`,\n\t\t\t\t\"\",\n\t\t\t\t`Run the remote Effect directly:`,\n\t\t\t\t` onclick={yield* UpvotePost(id)}`,\n\t\t\t\t\"\",\n\t\t\t\t`Recover from remote failures by composing the Effect value:`,\n\t\t\t\t` onclick={yield* UpvotePost(id).pipe(Effect.catch(() => Effect.void))}`,\n\t\t\t\t\"\",\n\t\t\t\t`Problematic expression:`,\n\t\t\t\texpression_text,\n\t\t\t].join(\"\\n\"),\n\t\t\tfilename,\n\t\t);\n\t\tthis.name = \"AsyncEffectInEventCallbackError\";\n\t\tthis.expression_text = expression_text;\n\t}\n}\n\n/**\n * Thrown when an event handler callback contains the old raw `yield*`\n * shorthand. Effectful event handlers must put `yield*` directly in the event\n * attribute so the callback boundary is generated by the markup runtime.\n *\n * @example\n * ```ts\n * throw new YieldStarInEventCallbackError(\"Component.svelte\", \"() => yield* save()\");\n * ```\n *\n * @since 2.0.0\n * @param filename - Svelte component filename used to identify where the\n * invalid event handler callback was found.\n * @param expression_text - Original event handler callback text that contained\n * `yield*` and should be rewritten as a direct event Effect expression.\n */\nexport class YieldStarInEventCallbackError extends PreprocessError {\n\t/**\n\t * The full text of the problematic event handler callback.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly expression_text: string;\n\n\tconstructor(filename: string, expression_text: string) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\tmake_error_message(\n\t\t\t\t\t\"ASYNC_EFFECT_IN_EVENT_HANDLER_CALLBACK\",\n\t\t\t\t\t`${filename}: yield* in markup event handlers must be written directly as the event attribute value.`,\n\t\t\t\t),\n\t\t\t\t`SER generates the event callback for effectful event handlers; do not put yield* inside a JavaScript callback.`,\n\t\t\t\t\"\",\n\t\t\t\t`Use this form:`,\n\t\t\t\t` onclick={yield* UpvotePost(id)}`,\n\t\t\t\t\"\",\n\t\t\t\t`Instead of this form:`,\n\t\t\t\t` onclick={() => yield* UpvotePost(id)}`,\n\t\t\t\t\"\",\n\t\t\t\t`Problematic expression:`,\n\t\t\t\texpression_text,\n\t\t\t].join(\"\\n\"),\n\t\t\tfilename,\n\t\t);\n\t\tthis.name = \"YieldStarInEventCallbackError\";\n\t\tthis.expression_text = expression_text;\n\t}\n}\n\n/**\n * Thrown when async Effect work appears in a markup position SER cannot lower\n * safely.\n *\n * @example\n * ```ts\n * throw new UnsupportedMarkupEffectPositionError(\n * \"Component.svelte\",\n * \"value={yield* load()}\",\n * );\n * ```\n *\n * @since 2.4.2\n * @param filename - Source filename containing the unsupported markup.\n * @param expression_text - The unsupported markup expression text.\n */\nexport class UnsupportedMarkupEffectPositionError extends PreprocessError {\n\t/**\n\t * The unsupported markup expression text.\n\t *\n\t * @since 2.4.2\n\t */\n\treadonly expression_text: string;\n\n\tconstructor(filename: string, expression_text: string) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\tmake_error_message(\n\t\t\t\t\t\"UNSUPPORTED_MARKUP_EFFECT_POSITION\",\n\t\t\t\t\t`${filename}: yield* cannot be used in this markup position.`,\n\t\t\t\t),\n\t\t\t\t`Move the Effect work into a supported expression tag, block expression, render expression, declaration tag, or event handler.`,\n\t\t\t\t\"\",\n\t\t\t\t`Problematic expression:`,\n\t\t\t\texpression_text,\n\t\t\t].join(\"\\n\"),\n\t\t\tfilename,\n\t\t);\n\t\tthis.name = \"UnsupportedMarkupEffectPositionError\";\n\t\tthis.expression_text = expression_text;\n\t}\n}\n\n/**\n * Thrown when the request-scoped SvelteKit event context is read outside a\n * remote handler.\n *\n * @example\n * ```ts\n * throw new RequestEventUnavailableError();\n * ```\n *\n * @since 2.4.0\n */\nexport class RequestEventUnavailableError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"RequestEvent is only available while a SER remote handler is executing inside a request-scoped Effect context.\",\n\t\t);\n\t\tthis.name = \"RequestEventUnavailableError\";\n\t}\n}\n\n/**\n * Thrown when an unchecked Query declaration omits the handler.\n *\n * @example\n * ```ts\n * throw new UncheckedQueryHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n */\nexport class UncheckedQueryHandlerMissingError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Query('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot execute by itself.\",\n\t\t);\n\t\tthis.name = \"UncheckedQueryHandlerMissingError\";\n\t}\n}\n\n/**\n * Thrown when a batch Query declaration omits the batch handler.\n *\n * @example\n * ```ts\n * throw new BatchQueryHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n */\nexport class BatchQueryHandlerMissingError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Query.batch requires a concrete batch handler function; the batch helper cannot infer a handler from schema metadata alone.\",\n\t\t);\n\t\tthis.name = \"BatchQueryHandlerMissingError\";\n\t}\n}\n\n/**\n * Thrown when an unchecked live Query declaration omits the handler.\n *\n * @example\n * ```ts\n * throw new UncheckedLiveQueryHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n */\nexport class UncheckedLiveQueryHandlerMissingError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Query.live('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot produce a live source.\",\n\t\t);\n\t\tthis.name = \"UncheckedLiveQueryHandlerMissingError\";\n\t}\n}\n\n/**\n * Thrown when an unchecked Command declaration omits the handler.\n *\n * @example\n * ```ts\n * throw new UncheckedCommandHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n */\nexport class UncheckedCommandHandlerMissingError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Command('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot execute a command.\",\n\t\t);\n\t\tthis.name = \"UncheckedCommandHandlerMissingError\";\n\t}\n}\n\n/**\n * Thrown when an unchecked Form declaration omits the handler.\n *\n * @example\n * ```ts\n * throw new UncheckedFormHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n */\nexport class UncheckedFormHandlerMissingError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Form('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot process form data.\",\n\t\t);\n\t\tthis.name = \"UncheckedFormHandlerMissingError\";\n\t}\n}\n\n/**\n * Thrown when an unchecked Prerender declaration omits the handler.\n *\n * @example\n * ```ts\n * throw new UncheckedPrerenderHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n */\nexport class UncheckedPrerenderHandlerMissingError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Prerender('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot produce prerendered data.\",\n\t\t);\n\t\tthis.name = \"UncheckedPrerenderHandlerMissingError\";\n\t}\n}\n\n/**\n * Thrown when a live query handler resolves to a value that cannot be streamed.\n *\n * @example\n * ```ts\n * throw new InvalidLiveQueryReturnError();\n * ```\n *\n * @since 2.4.0\n */\nexport class InvalidLiveQueryReturnError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Query.live handler must return an Effect Stream. Wrap native iterables with Stream.fromIterable, Stream.fromAsyncIterable, or another Stream constructor before returning them.\",\n\t\t);\n\t\tthis.name = \"InvalidLiveQueryReturnError\";\n\t}\n}\n\n/**\n * Thrown when generated component code yields a Stream that completes before\n * producing a value.\n *\n * @example\n * ```ts\n * throw new EmptyStreamYieldError();\n * ```\n *\n * @since 3.4.8\n */\nexport class EmptyStreamYieldError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Cannot resolve yield* stream expression because the Stream completed without emitting a value.\",\n\t\t);\n\t\tthis.name = \"EmptyStreamYieldError\";\n\t}\n}\n\n/**\n * Thrown when generated component code receives a value that cannot be yielded\n * through the SER runtime.\n *\n * @example\n * ```ts\n * throw new InvalidYieldableError(null);\n * ```\n *\n * @since 4.0.0\n * @param value - Runtime value that was expected to be an Effect, generator, or\n * Stream.\n */\nexport class InvalidYieldableError extends RuntimeError {\n\t/**\n\t * Runtime value rejected by the generated yield boundary.\n\t *\n\t * @since 4.0.0\n\t */\n\treadonly value: unknown;\n\n\tconstructor(value: unknown) {\n\t\tsuper(\n\t\t\t\"Cannot resolve yield* expression because it returned a non-yieldable value. Expected an Effect, generator, or Stream.\",\n\t\t);\n\t\tthis.name = \"InvalidYieldableError\";\n\t\tthis.value = value;\n\t}\n}\n\n/**\n * Thrown when a dispatcher operation is requested after disposal.\n *\n * @example\n * ```ts\n * throw new DispatcherDisposedError();\n * ```\n *\n * @since 2.4.0\n */\nexport class DispatcherDisposedError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Dispatcher has been disposed; no new Effect fibers or promise bridges can be started after component teardown.\",\n\t\t);\n\t\tthis.name = \"DispatcherDisposedError\";\n\t}\n}\n\n/**\n * Thrown when an application attempts to configure a runtime after one has\n * already been initialized.\n *\n * @example\n * ```ts\n * throw new RuntimeAlreadyInitializedError(\"ClientRuntime\");\n * ```\n *\n * @since 3.4.0\n * @param runtime_name - Public runtime API that was initialized more than once.\n */\nexport class RuntimeAlreadyInitializedError extends RuntimeError {\n\tconstructor(runtime_name: string) {\n\t\tsuper(\n\t\t\tmake_error_message(\n\t\t\t\t\"RUNTIME_ALREADY_INITIALIZED\",\n\t\t\t\t`${runtime_name}.make(...) cannot be called because the runtime has already been initialized. Configure it once during application startup, before any Effect-backed component, remote handler, or generated runtime code runs.`,\n\t\t\t),\n\t\t);\n\t\tthis.name = \"RuntimeAlreadyInitializedError\";\n\t}\n}\n\n/**\n * Thrown when a generated or native remote query export is not callable.\n *\n * @example\n * ```ts\n * throw new InvalidQueryFactoryError();\n * ```\n *\n * @since 2.4.0\n */\nexport class InvalidQueryFactoryError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Invalid query factory: expected a function or an object exposing query/load methods from SvelteKit remote query generation.\",\n\t\t);\n\t\tthis.name = \"InvalidQueryFactoryError\";\n\t}\n}\n\n/**\n * Thrown when a generated or native remote prerender export is not callable.\n *\n * @since 4.0.0\n */\nexport class InvalidPrerenderFactoryError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Invalid prerender factory: expected a function from SvelteKit remote prerender generation.\",\n\t\t);\n\t\tthis.name = \"InvalidPrerenderFactoryError\";\n\t}\n}\n\n/**\n * Thrown when a generated or native remote live query export is not callable.\n *\n * @example\n * ```ts\n * throw new InvalidLiveQueryFactoryError();\n * ```\n *\n * @since 2.4.0\n */\nexport class InvalidLiveQueryFactoryError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Invalid live query factory: expected a function or an object exposing a query method from SvelteKit remote live query generation.\",\n\t\t);\n\t\tthis.name = \"InvalidLiveQueryFactoryError\";\n\t}\n}\n\n/**\n * Thrown when a generated or native remote command export is not callable.\n *\n * @example\n * ```ts\n * throw new InvalidCommandFactoryError();\n * ```\n *\n * @since 2.4.0\n */\nexport class InvalidCommandFactoryError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Invalid command factory: expected a function or an object exposing an invoke method from SvelteKit remote command generation.\",\n\t\t);\n\t\tthis.name = \"InvalidCommandFactoryError\";\n\t}\n}\n\n/**\n * Thrown when the client-side form adapter cannot derive a remote endpoint.\n *\n * @example\n * ```ts\n * throw new RemoteFormEndpointMissingError();\n * ```\n *\n * @since 2.4.0\n */\nexport class RemoteFormEndpointMissingError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Form has no submit method or remote endpoint; the adapted SvelteKit form object does not expose an action id and no remote base URL was generated.\",\n\t\t);\n\t\tthis.name = \"RemoteFormEndpointMissingError\";\n\t}\n}\n\n/**\n * Thrown when a remote form response envelope is not an object with a response\n * type.\n *\n * @example\n * ```ts\n * throw new InvalidRemoteFormResponseError(envelope);\n * ```\n *\n * @since 2.4.0\n * @param envelope - Raw response envelope returned by the remote form endpoint.\n */\nexport class InvalidRemoteFormResponseError extends RuntimeError {\n\t/**\n\t * Raw response envelope returned by the remote form endpoint.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly envelope: unknown;\n\n\tconstructor(envelope?: unknown) {\n\t\tsuper(\n\t\t\t\"Invalid remote form response: expected an object envelope with a string type field returned by SvelteKit remote form transport.\",\n\t\t);\n\t\tthis.name = \"InvalidRemoteFormResponseError\";\n\t\tthis.envelope = envelope;\n\t}\n}\n\n/**\n * Thrown when a remote form response has a well-formed envelope but an\n * unsupported response type or payload slot.\n *\n * @example\n * ```ts\n * throw new UnsupportedRemoteFormResponseError(envelope);\n * ```\n *\n * @since 2.4.0\n * @param envelope - Raw response envelope returned by the remote form endpoint.\n */\nexport class UnsupportedRemoteFormResponseError extends RuntimeError {\n\t/**\n\t * Raw response envelope returned by the remote form endpoint.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly envelope: unknown;\n\n\tconstructor(envelope?: unknown) {\n\t\tsuper(\n\t\t\t\"Unsupported remote form response: expected a result envelope with a devalue-encoded result or data string.\",\n\t\t);\n\t\tthis.name = \"UnsupportedRemoteFormResponseError\";\n\t\tthis.envelope = envelope;\n\t}\n}\n\n/**\n * Thrown when a serialized remote failure envelope cannot be decoded.\n *\n * @example\n * ```ts\n * throw new RemoteErrorDecodeError(raw);\n * ```\n *\n * @since 2.4.0\n * @param raw - Raw serialized remote failure payload that failed decoding.\n */\nexport class RemoteErrorDecodeError extends RuntimeError {\n\t/**\n\t * Raw serialized remote failure payload that failed decoding.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly raw: unknown;\n\n\tconstructor(raw?: unknown) {\n\t\tsuper(\n\t\t\t\"Failed to decode remote error payload: expected a devalue-encoded SER remote failure envelope compatible with the client decoder.\",\n\t\t);\n\t\tthis.name = \"RemoteErrorDecodeError\";\n\t\tthis.raw = raw;\n\t}\n}\n\n/**\n * Thrown when a root server-only helper is imported without Vite rewriting.\n *\n * @example\n * ```ts\n * throw new ServerOnlyImportError(\"Query\");\n * ```\n *\n * @since 2.4.0\n * @param export_name - Name of the server-only root export that was invoked.\n */\nexport class ServerOnlyImportError extends RuntimeError {\n\t/**\n\t * Name of the server-only root export that was invoked.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly export_name: string;\n\n\tconstructor(export_name: string) {\n\t\tsuper(\n\t\t\t`${export_name} is only available in SvelteKit server files. Ensure the SER Vite plugin is enabled so root imports are rewritten to svelte-effect-runtime/server before execution.`,\n\t\t);\n\t\tthis.name = \"ServerOnlyImportError\";\n\t\tthis.export_name = export_name;\n\t}\n}\n\n/**\n * Thrown when the publish-time `$app/server` shim executes outside SvelteKit.\n *\n * @example\n * ```ts\n * throw new SvelteKitServerExportUnavailableError(\"query\");\n * ```\n *\n * @since 2.4.0\n * @param export_name - Name of the `$app/server` export that was invoked.\n */\nexport class SvelteKitServerExportUnavailableError extends RuntimeError {\n\t/**\n\t * Name of the `$app/server` export that was invoked.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly export_name: string;\n\n\tconstructor(export_name: string) {\n\t\tsuper(\n\t\t\t`SvelteKit virtual $app/server export ${export_name} is only available inside a SvelteKit server module.`,\n\t\t);\n\t\tthis.name = \"SvelteKitServerExportUnavailableError\";\n\t\tthis.export_name = export_name;\n\t}\n}\n\n/**\n * Thrown when a SvelteKit remote helper reports that it was called outside the\n * route-scoped remote module context.\n *\n * @example\n * ```ts\n * throw new RemoteHelperContextError(\"Query\");\n * ```\n *\n * @since 2.4.0\n * @param helper_name - SER helper name that triggered the context failure.\n */\nexport class RemoteHelperContextError extends RuntimeError {\n\t/**\n\t * SER helper name that triggered the context failure.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly helper_name: string;\n\n\tconstructor(helper_name: string) {\n\t\tsuper(\n\t\t\tmake_error_message(\n\t\t\t\t\"REMOTE_HELPER_CONTEXT\",\n\t\t\t\t`${helper_name} was called outside a .remote.ts file. Ensure the file is named \\`*.remote.ts\\` and is located in a route directory so SvelteKit can bind remote helper context.`,\n\t\t\t),\n\t\t);\n\t\tthis.name = \"RemoteHelperContextError\";\n\t\tthis.helper_name = helper_name;\n\t}\n}\n\n/**\n * Thrown when a SvelteKit remote helper normalizes a non-Error thrown value.\n *\n * @example\n * ```ts\n * throw new RemoteHelperError(\"raw failure\");\n * ```\n *\n * @since 2.4.0\n * @param value - Non-Error value thrown while creating a remote helper.\n */\nexport class RemoteHelperError extends RuntimeError {\n\t/**\n\t * Non-Error value that was normalized.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly value: unknown;\n\n\tconstructor(value: unknown) {\n\t\tsuper(make_error_message(\"REMOTE_HELPER_ERROR\", String(value)));\n\t\tthis.name = \"RemoteHelperError\";\n\t\tthis.value = value;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;AAcA,IAAa,eAAb,cAAkC,MAAM;CACvC,YAAY,SAAiB;EAC5B,MAAM,OAAO;EACb,KAAK,OAAO;CACb;AACD;AAEA,SAAgB,mBAAmB,MAAc,SAAyB;CACzE,OAAO,IAAI,KAAK,KAAK;AACtB;;;;;;;;;;;;;;;AAgBA,IAAa,kBAAb,cAAqC,aAAa;;;;;;CAMjD;CAEA,YAAY,SAAiB,UAAkB;EAC9C,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,WAAW;CACjB;AACD;;;;;;;;;;;;;;;AAgBA,IAAa,yBAAb,cAA4C,gBAAgB;;;;;;CAM3D;CAEA,YAAY,UAAkB,gBAAwB;EACrD,MACC;GACC,mBACC,wBACA,GAAG,SAAS,oDACb;GACA;GACA;GACA;GACA;EACD,CAAC,CAAC,KAAK,IAAI,GACX,QACD;EACA,KAAK,OAAO;EACZ,KAAK,iBAAiB;C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AAY,aAAqB;EAChC,MACC,mBACC,yBACA,GAAG,YAAY,iKAChB,CACD;EACA,KAAK,OAAO;EACZ,KAAK,cAAc;CACpB;AACD;;;;;;;;;;;;AAaA,IAAa,oBAAb,cAAuC,aAAa;;;;;;CAMnD;CAEA,YAAY,OAAgB;EAC3B,MAAM,mBAAmB,uBAAuB,OAAO,KAAK,CAAC,CAAC;EAC9D,KAAK,OAAO;EACZ,KAAK,QAAQ;CACd;AACD"}
|
|
1
|
+
{"version":3,"file":"errors-qhcbUH6o.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/errors.ts"],"sourcesContent":["/**\n * Base class for runtime-authored errors. The class gives every local failure\n * a stable JavaScript error name while preserving the technical message that\n * reaches Vite, SvelteKit, and test output.\n *\n * @example\n * ```ts\n * throw new RuntimeError(\"Invariant violated.\");\n * ```\n *\n * @since 2.4.0\n * @param message - Technical diagnostic message describing the failed runtime\n * invariant.\n */\nexport class RuntimeError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"RuntimeError\";\n\t}\n}\n\nexport function make_error_message(code: string, message: string): string {\n\treturn `[${code}]: ${message}`;\n}\n\n/**\n * Base error class for all preprocessor errors emitted during script and\n * markup transformation. Carries the source filename so error messages can\n * reference the affected file.\n *\n * @example\n * ```ts\n * throw new PreprocessError(\"Component.svelte: invalid transform input.\", \"Component.svelte\");\n * ```\n *\n * @since 2.0.0\n * @param message - Technical diagnostic message for the transform failure.\n * @param filename - Source filename that triggered the transform failure.\n */\nexport class PreprocessError extends RuntimeError {\n\t/**\n\t * The source filename that triggered this error.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly filename: string;\n\n\tconstructor(message: string, filename: string) {\n\t\tsuper(message);\n\t\tthis.name = \"PreprocessError\";\n\t\tthis.filename = filename;\n\t}\n}\n\n/**\n * Thrown when a statement mixes JavaScript `await` with Effect `yield*` work\n * that must be lowered into an `Effect.gen` program.\n *\n * @example\n * ```ts\n * throw new AwaitInEffectWorkError(\"Component.svelte\", \"const value = await load();\");\n * ```\n *\n * @since 2.0.0\n * @param filename - Source filename containing the unsupported statement.\n * @param statement_text - Full source text for the statement containing\n * mixed async work.\n */\nexport class AwaitInEffectWorkError extends PreprocessError {\n\t/**\n\t * The full text of the problematic statement containing mixed async work.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly statement_text: string;\n\n\tconstructor(filename: string, statement_text: string) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\tmake_error_message(\n\t\t\t\t\t\"AWAIT_IN_EFFECT_WORK\",\n\t\t\t\t\t`${filename}: await cannot be mixed with yield* in Effect work.`,\n\t\t\t\t),\n\t\t\t\t`Top-level await is supported as ordinary Svelte async rendering, but statements lowered into Effect.gen must use yield* for async Effect work.`,\n\t\t\t\t\"\",\n\t\t\t\t`Problematic statement:`,\n\t\t\t\tstatement_text,\n\t\t\t].join(\"\\n\"),\n\t\t\tfilename,\n\t\t);\n\t\tthis.name = \"AwaitInEffectWorkError\";\n\t\tthis.statement_text = statement_text;\n\t}\n}\n\n/**\n * Thrown when async Effect work appears inside a Svelte rune position that\n * must stay synchronous.\n *\n * @example\n * ```ts\n * throw new AsyncEffectInSyncRuneError(\"$derived\", \"$derived(yield* load())\", \"Component.svelte\");\n * ```\n *\n * @since 2.0.0\n * @param rune_name - Name of the Svelte rune containing the unsupported async\n * Effect work.\n * @param expression_text - Full source text for the rune expression.\n * @param filename - Source filename containing the unsupported rune.\n */\nexport class AsyncEffectInSyncRuneError extends PreprocessError {\n\t/**\n\t * The name of the rune that contained async Effect work.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly rune_name: string;\n\n\t/**\n\t * The full text of the expression that triggered the error.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly expression_text: string;\n\n\tconstructor(rune_name: string, expression_text: string, filename: string) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\tmake_error_message(\n\t\t\t\t\t\"ASYNC_EFFECT_IN_SYNC_RUNE\",\n\t\t\t\t\t`${filename}: yield* cannot be used inside ${rune_name}().`,\n\t\t\t\t),\n\t\t\t\t`${rune_name}() must stay synchronous. Do not put async Effect work inside this rune.`,\n\t\t\t\t\"\",\n\t\t\t\t`Problematic expression:`,\n\t\t\t\texpression_text,\n\t\t\t].join(\"\\n\"),\n\t\t\tfilename,\n\t\t);\n\t\tthis.name = \"AsyncEffectInSyncRuneError\";\n\t\tthis.rune_name = rune_name;\n\t\tthis.expression_text = expression_text;\n\t}\n}\n\n/**\n * Thrown when async Effect work appears inside a non-generator callback nested\n * in a markup event handler.\n *\n * @example\n * ```ts\n * throw new AsyncEffectInEventCallbackError(\n * \"Component.svelte\",\n * \"Effect.try(() => yield* save())\",\n * );\n * ```\n *\n * @since 2.0.0\n * @param filename - Source filename containing the invalid event handler.\n * @param expression_text - Event handler expression that contains the nested\n * unsupported async Effect work.\n */\nexport class AsyncEffectInEventCallbackError extends PreprocessError {\n\t/**\n\t * The full text of the problematic event handler body.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly expression_text: string;\n\n\tconstructor(filename: string, expression_text: string) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\tmake_error_message(\n\t\t\t\t\t\"ASYNC_EFFECT_IN_EVENT_CALLBACK\",\n\t\t\t\t\t`${filename}: yield* cannot be used inside a nested non-generator callback in a markup event handler.`,\n\t\t\t\t),\n\t\t\t\t`Move the yield* to the event handler body. Effect.try and Effect.sync callbacks are plain synchronous JavaScript; do not call Effect-returning functions inside them.`,\n\t\t\t\t\"\",\n\t\t\t\t`Run the remote Effect directly:`,\n\t\t\t\t` onclick={yield* UpvotePost(id)}`,\n\t\t\t\t\"\",\n\t\t\t\t`Recover from remote failures by composing the Effect value:`,\n\t\t\t\t` onclick={yield* UpvotePost(id).pipe(Effect.catch(() => Effect.void))}`,\n\t\t\t\t\"\",\n\t\t\t\t`Problematic expression:`,\n\t\t\t\texpression_text,\n\t\t\t].join(\"\\n\"),\n\t\t\tfilename,\n\t\t);\n\t\tthis.name = \"AsyncEffectInEventCallbackError\";\n\t\tthis.expression_text = expression_text;\n\t}\n}\n\n/**\n * Thrown when an event handler callback contains the old raw `yield*`\n * shorthand. Effectful event handlers must put `yield*` directly in the event\n * attribute so the callback boundary is generated by the markup runtime.\n *\n * @example\n * ```ts\n * throw new YieldStarInEventCallbackError(\"Component.svelte\", \"() => yield* save()\");\n * ```\n *\n * @since 2.0.0\n * @param filename - Svelte component filename used to identify where the\n * invalid event handler callback was found.\n * @param expression_text - Original event handler callback text that contained\n * `yield*` and should be rewritten as a direct event Effect expression.\n */\nexport class YieldStarInEventCallbackError extends PreprocessError {\n\t/**\n\t * The full text of the problematic event handler callback.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly expression_text: string;\n\n\tconstructor(filename: string, expression_text: string) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\tmake_error_message(\n\t\t\t\t\t\"ASYNC_EFFECT_IN_EVENT_HANDLER_CALLBACK\",\n\t\t\t\t\t`${filename}: yield* in markup event handlers must be written directly as the event attribute value.`,\n\t\t\t\t),\n\t\t\t\t`SER generates the event callback for effectful event handlers; do not put yield* inside a JavaScript callback.`,\n\t\t\t\t\"\",\n\t\t\t\t`Use this form:`,\n\t\t\t\t` onclick={yield* UpvotePost(id)}`,\n\t\t\t\t\"\",\n\t\t\t\t`Instead of this form:`,\n\t\t\t\t` onclick={() => yield* UpvotePost(id)}`,\n\t\t\t\t\"\",\n\t\t\t\t`Problematic expression:`,\n\t\t\t\texpression_text,\n\t\t\t].join(\"\\n\"),\n\t\t\tfilename,\n\t\t);\n\t\tthis.name = \"YieldStarInEventCallbackError\";\n\t\tthis.expression_text = expression_text;\n\t}\n}\n\n/**\n * Thrown when async Effect work appears in a markup position SER cannot lower\n * safely.\n *\n * @example\n * ```ts\n * throw new UnsupportedMarkupEffectPositionError(\n * \"Component.svelte\",\n * \"value={yield* load()}\",\n * );\n * ```\n *\n * @since 2.4.2\n * @param filename - Source filename containing the unsupported markup.\n * @param expression_text - The unsupported markup expression text.\n */\nexport class UnsupportedMarkupEffectPositionError extends PreprocessError {\n\t/**\n\t * The unsupported markup expression text.\n\t *\n\t * @since 2.4.2\n\t */\n\treadonly expression_text: string;\n\n\tconstructor(filename: string, expression_text: string) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\tmake_error_message(\n\t\t\t\t\t\"UNSUPPORTED_MARKUP_EFFECT_POSITION\",\n\t\t\t\t\t`${filename}: yield* cannot be used in this markup position.`,\n\t\t\t\t),\n\t\t\t\t`Move the Effect work into a supported expression tag, block expression, render expression, declaration tag, or event handler.`,\n\t\t\t\t\"\",\n\t\t\t\t`Problematic expression:`,\n\t\t\t\texpression_text,\n\t\t\t].join(\"\\n\"),\n\t\t\tfilename,\n\t\t);\n\t\tthis.name = \"UnsupportedMarkupEffectPositionError\";\n\t\tthis.expression_text = expression_text;\n\t}\n}\n\n/**\n * Thrown when the request-scoped SvelteKit event context is read outside a\n * remote handler.\n *\n * @example\n * ```ts\n * throw new RequestEventUnavailableError();\n * ```\n *\n * @since 2.4.0\n */\nexport class RequestEventUnavailableError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"RequestEvent is only available while a SER remote handler is executing inside a request-scoped Effect context.\",\n\t\t);\n\t\tthis.name = \"RequestEventUnavailableError\";\n\t}\n}\n\n/**\n * Thrown when an unchecked Query declaration omits the handler.\n *\n * @example\n * ```ts\n * throw new UncheckedQueryHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n */\nexport class UncheckedQueryHandlerMissingError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Query('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot execute by itself.\",\n\t\t);\n\t\tthis.name = \"UncheckedQueryHandlerMissingError\";\n\t}\n}\n\n/**\n * Thrown when a batch Query declaration omits the batch handler.\n *\n * @example\n * ```ts\n * throw new BatchQueryHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n */\nexport class BatchQueryHandlerMissingError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Query.batch requires a concrete batch handler function; the batch helper cannot infer a handler from schema metadata alone.\",\n\t\t);\n\t\tthis.name = \"BatchQueryHandlerMissingError\";\n\t}\n}\n\n/**\n * Thrown when an unchecked live Query declaration omits the handler.\n *\n * @example\n * ```ts\n * throw new UncheckedLiveQueryHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n */\nexport class UncheckedLiveQueryHandlerMissingError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Query.live('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot produce a live source.\",\n\t\t);\n\t\tthis.name = \"UncheckedLiveQueryHandlerMissingError\";\n\t}\n}\n\n/**\n * Thrown when an unchecked Command declaration omits the handler.\n *\n * @example\n * ```ts\n * throw new UncheckedCommandHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n */\nexport class UncheckedCommandHandlerMissingError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Command('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot execute a command.\",\n\t\t);\n\t\tthis.name = \"UncheckedCommandHandlerMissingError\";\n\t}\n}\n\n/**\n * Thrown when an unchecked Form declaration omits the handler.\n *\n * @example\n * ```ts\n * throw new UncheckedFormHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n */\nexport class UncheckedFormHandlerMissingError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Form('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot process form data.\",\n\t\t);\n\t\tthis.name = \"UncheckedFormHandlerMissingError\";\n\t}\n}\n\n/**\n * Thrown when an unchecked Prerender declaration omits the handler.\n *\n * @example\n * ```ts\n * throw new UncheckedPrerenderHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n */\nexport class UncheckedPrerenderHandlerMissingError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Prerender('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot produce prerendered data.\",\n\t\t);\n\t\tthis.name = \"UncheckedPrerenderHandlerMissingError\";\n\t}\n}\n\n/**\n * Thrown when a live query handler resolves to a value that cannot be streamed.\n *\n * @example\n * ```ts\n * throw new InvalidLiveQueryReturnError();\n * ```\n *\n * @since 2.4.0\n */\nexport class InvalidLiveQueryReturnError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Query.live handler must return an Effect Stream. Wrap native iterables with Stream.fromIterable, Stream.fromAsyncIterable, or another Stream constructor before returning them.\",\n\t\t);\n\t\tthis.name = \"InvalidLiveQueryReturnError\";\n\t}\n}\n\n/**\n * Thrown when generated component code yields a Stream that completes before\n * producing a value.\n *\n * @example\n * ```ts\n * throw new EmptyStreamYieldError();\n * ```\n *\n * @since 3.4.8\n */\nexport class EmptyStreamYieldError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Cannot resolve yield* stream expression because the Stream completed without emitting a value.\",\n\t\t);\n\t\tthis.name = \"EmptyStreamYieldError\";\n\t}\n}\n\n/**\n * Thrown when generated component code receives a value that cannot be yielded\n * through the SER runtime.\n *\n * @example\n * ```ts\n * throw new InvalidYieldableError(null);\n * ```\n *\n * @since 4.0.0\n * @param value - Runtime value that was expected to be an Effect, generator, or\n * Stream.\n */\nexport class InvalidYieldableError extends RuntimeError {\n\t/**\n\t * Runtime value rejected by the generated yield boundary.\n\t *\n\t * @since 4.0.0\n\t */\n\treadonly value: unknown;\n\n\tconstructor(value: unknown) {\n\t\tsuper(\n\t\t\t\"Cannot resolve yield* expression because it returned a non-yieldable value. Expected an Effect, generator, or Stream.\",\n\t\t);\n\t\tthis.name = \"InvalidYieldableError\";\n\t\tthis.value = value;\n\t}\n}\n\n/**\n * Thrown when a dispatcher operation is requested after disposal.\n *\n * @example\n * ```ts\n * throw new DispatcherDisposedError();\n * ```\n *\n * @since 2.4.0\n */\nexport class DispatcherDisposedError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Dispatcher has been disposed; no new Effect fibers or promise bridges can be started after component teardown.\",\n\t\t);\n\t\tthis.name = \"DispatcherDisposedError\";\n\t}\n}\n\n/**\n * Thrown when Effect work is bound to a component scope that has already been\n * disposed.\n *\n * @example\n * ```ts\n * throw new ScopeDisposedError();\n * ```\n *\n * @since 3.1.0\n */\nexport class ScopeDisposedError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Effect scope has been disposed; no new Effect work can be bound to a destroyed component's scope.\",\n\t\t);\n\t\tthis.name = \"ScopeDisposedError\";\n\t}\n}\n\n/**\n * Thrown when an application attempts to configure a runtime after one has\n * already been initialized.\n *\n * @example\n * ```ts\n * throw new RuntimeAlreadyInitializedError(\"ClientRuntime\");\n * ```\n *\n * @since 3.4.0\n * @param runtime_name - Public runtime API that was initialized more than once.\n */\nexport class RuntimeAlreadyInitializedError extends RuntimeError {\n\tconstructor(runtime_name: string) {\n\t\tsuper(\n\t\t\tmake_error_message(\n\t\t\t\t\"RUNTIME_ALREADY_INITIALIZED\",\n\t\t\t\t`${runtime_name}.make(...) cannot be called because the runtime has already been initialized. Configure it once during application startup, before any Effect-backed component, remote handler, or generated runtime code runs.`,\n\t\t\t),\n\t\t);\n\t\tthis.name = \"RuntimeAlreadyInitializedError\";\n\t}\n}\n\n/**\n * Thrown when a generated or native remote query export is not callable.\n *\n * @example\n * ```ts\n * throw new InvalidQueryFactoryError();\n * ```\n *\n * @since 2.4.0\n */\nexport class InvalidQueryFactoryError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Invalid query factory: expected a function or an object exposing query/load methods from SvelteKit remote query generation.\",\n\t\t);\n\t\tthis.name = \"InvalidQueryFactoryError\";\n\t}\n}\n\n/**\n * Thrown when a generated or native remote prerender export is not callable.\n *\n * @since 4.0.0\n */\nexport class InvalidPrerenderFactoryError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Invalid prerender factory: expected a function from SvelteKit remote prerender generation.\",\n\t\t);\n\t\tthis.name = \"InvalidPrerenderFactoryError\";\n\t}\n}\n\n/**\n * Thrown when a generated or native remote live query export is not callable.\n *\n * @example\n * ```ts\n * throw new InvalidLiveQueryFactoryError();\n * ```\n *\n * @since 2.4.0\n */\nexport class InvalidLiveQueryFactoryError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Invalid live query factory: expected a function or an object exposing a query method from SvelteKit remote live query generation.\",\n\t\t);\n\t\tthis.name = \"InvalidLiveQueryFactoryError\";\n\t}\n}\n\n/**\n * Thrown when a generated or native remote command export is not callable.\n *\n * @example\n * ```ts\n * throw new InvalidCommandFactoryError();\n * ```\n *\n * @since 2.4.0\n */\nexport class InvalidCommandFactoryError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Invalid command factory: expected a function or an object exposing an invoke method from SvelteKit remote command generation.\",\n\t\t);\n\t\tthis.name = \"InvalidCommandFactoryError\";\n\t}\n}\n\n/**\n * Thrown when the client-side form adapter cannot derive a remote endpoint.\n *\n * @example\n * ```ts\n * throw new RemoteFormEndpointMissingError();\n * ```\n *\n * @since 2.4.0\n */\nexport class RemoteFormEndpointMissingError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Form has no submit method or remote endpoint; the adapted SvelteKit form object does not expose an action id and no remote base URL was generated.\",\n\t\t);\n\t\tthis.name = \"RemoteFormEndpointMissingError\";\n\t}\n}\n\n/**\n * Thrown when a remote form response envelope is not an object with a response\n * type.\n *\n * @example\n * ```ts\n * throw new InvalidRemoteFormResponseError(envelope);\n * ```\n *\n * @since 2.4.0\n * @param envelope - Raw response envelope returned by the remote form endpoint.\n */\nexport class InvalidRemoteFormResponseError extends RuntimeError {\n\t/**\n\t * Raw response envelope returned by the remote form endpoint.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly envelope: unknown;\n\n\tconstructor(envelope?: unknown) {\n\t\tsuper(\n\t\t\t\"Invalid remote form response: expected an object envelope with a string type field returned by SvelteKit remote form transport.\",\n\t\t);\n\t\tthis.name = \"InvalidRemoteFormResponseError\";\n\t\tthis.envelope = envelope;\n\t}\n}\n\n/**\n * Thrown when a remote form response has a well-formed envelope but an\n * unsupported response type or payload slot.\n *\n * @example\n * ```ts\n * throw new UnsupportedRemoteFormResponseError(envelope);\n * ```\n *\n * @since 2.4.0\n * @param envelope - Raw response envelope returned by the remote form endpoint.\n */\nexport class UnsupportedRemoteFormResponseError extends RuntimeError {\n\t/**\n\t * Raw response envelope returned by the remote form endpoint.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly envelope: unknown;\n\n\tconstructor(envelope?: unknown) {\n\t\tsuper(\n\t\t\t\"Unsupported remote form response: expected a result envelope with a devalue-encoded result or data string.\",\n\t\t);\n\t\tthis.name = \"UnsupportedRemoteFormResponseError\";\n\t\tthis.envelope = envelope;\n\t}\n}\n\n/**\n * Thrown when a serialized remote failure envelope cannot be decoded.\n *\n * @example\n * ```ts\n * throw new RemoteErrorDecodeError(raw);\n * ```\n *\n * @since 2.4.0\n * @param raw - Raw serialized remote failure payload that failed decoding.\n */\nexport class RemoteErrorDecodeError extends RuntimeError {\n\t/**\n\t * Raw serialized remote failure payload that failed decoding.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly raw: unknown;\n\n\tconstructor(raw?: unknown) {\n\t\tsuper(\n\t\t\t\"Failed to decode remote error payload: expected a devalue-encoded SER remote failure envelope compatible with the client decoder.\",\n\t\t);\n\t\tthis.name = \"RemoteErrorDecodeError\";\n\t\tthis.raw = raw;\n\t}\n}\n\n/**\n * Thrown when a root server-only helper is imported without Vite rewriting.\n *\n * @example\n * ```ts\n * throw new ServerOnlyImportError(\"Query\");\n * ```\n *\n * @since 2.4.0\n * @param export_name - Name of the server-only root export that was invoked.\n */\nexport class ServerOnlyImportError extends RuntimeError {\n\t/**\n\t * Name of the server-only root export that was invoked.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly export_name: string;\n\n\tconstructor(export_name: string) {\n\t\tsuper(\n\t\t\t`${export_name} is only available in SvelteKit server files. Ensure the SER Vite plugin is enabled so root imports are rewritten to svelte-effect-runtime/server before execution.`,\n\t\t);\n\t\tthis.name = \"ServerOnlyImportError\";\n\t\tthis.export_name = export_name;\n\t}\n}\n\n/**\n * Thrown when the publish-time `$app/server` shim executes outside SvelteKit.\n *\n * @example\n * ```ts\n * throw new SvelteKitServerExportUnavailableError(\"query\");\n * ```\n *\n * @since 2.4.0\n * @param export_name - Name of the `$app/server` export that was invoked.\n */\nexport class SvelteKitServerExportUnavailableError extends RuntimeError {\n\t/**\n\t * Name of the `$app/server` export that was invoked.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly export_name: string;\n\n\tconstructor(export_name: string) {\n\t\tsuper(\n\t\t\t`SvelteKit virtual $app/server export ${export_name} is only available inside a SvelteKit server module.`,\n\t\t);\n\t\tthis.name = \"SvelteKitServerExportUnavailableError\";\n\t\tthis.export_name = export_name;\n\t}\n}\n\n/**\n * Thrown when a SvelteKit remote helper reports that it was called outside the\n * route-scoped remote module context.\n *\n * @example\n * ```ts\n * throw new RemoteHelperContextError(\"Query\");\n * ```\n *\n * @since 2.4.0\n * @param helper_name - SER helper name that triggered the context failure.\n */\nexport class RemoteHelperContextError extends RuntimeError {\n\t/**\n\t * SER helper name that triggered the context failure.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly helper_name: string;\n\n\tconstructor(helper_name: string) {\n\t\tsuper(\n\t\t\tmake_error_message(\n\t\t\t\t\"REMOTE_HELPER_CONTEXT\",\n\t\t\t\t`${helper_name} was called outside a .remote.ts file. Ensure the file is named \\`*.remote.ts\\` and is located in a route directory so SvelteKit can bind remote helper context.`,\n\t\t\t),\n\t\t);\n\t\tthis.name = \"RemoteHelperContextError\";\n\t\tthis.helper_name = helper_name;\n\t}\n}\n\n/**\n * Thrown when a SvelteKit remote helper normalizes a non-Error thrown value.\n *\n * @example\n * ```ts\n * throw new RemoteHelperError(\"raw failure\");\n * ```\n *\n * @since 2.4.0\n * @param value - Non-Error value thrown while creating a remote helper.\n */\nexport class RemoteHelperError extends RuntimeError {\n\t/**\n\t * Non-Error value that was normalized.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly value: unknown;\n\n\tconstructor(value: unknown) {\n\t\tsuper(make_error_message(\"REMOTE_HELPER_ERROR\", String(value)));\n\t\tthis.name = \"RemoteHelperError\";\n\t\tthis.value = value;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;AAcA,IAAa,eAAb,cAAkC,MAAM;CACvC,YAAY,SAAiB;EAC5B,MAAM,OAAO;EACb,KAAK,OAAO;CACb;AACD;AAEA,SAAgB,mBAAmB,MAAc,SAAyB;CACzE,OAAO,IAAI,KAAK,KAAK;AACtB;;;;;;;;;;;;;;;AAgBA,IAAa,kBAAb,cAAqC,aAAa;;;;;;CAMjD;CAEA,YAAY,SAAiB,UAAkB;EAC9C,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,WAAW;CACjB;AACD;;;;;;;;;;;;;;;AAgBA,IAAa,yBAAb,cAA4C,gBAAgB;;;;;;CAM3D;CAEA,YAAY,UAAkB,gBAAwB;EACrD,MACC;GACC,mBACC,wBACA,GAAG,SAAS,oDACb;GACA;GACA;GACA;GACA;EACD,CAAC,CAAC,KAAK,IAAI,GACX,QACD;EACA,KAAK,OAAO;EACZ,KAAK,iBAAiB;CACvB;AACD;;;;;;;;;;;;;;;;AAiBA,IAAa,6BAAb,cAAgD,gBAAgB;;;;;;CAM/D;;;;;;CAOA;CAEA,YAAY,WAAmB,iBAAyB,UAAkB;EACzE,MACC;GACC,mBACC,6BACA,GAAG,SAAS,iCAAiC,UAAU,IACxD;GACA,GAAG,UAAU;GACb;GACA;GACA;EACD,CAAC,CAAC,KAAK,IAAI,GACX,QACD;EACA,KAAK,OAAO;EACZ,KAAK,YAAY;EACjB,KAAK,kBAAkB;CACxB;AACD;;;;;;;;;;;;;;;;;;AAmBA,IAAa,kCAAb,cAAqD,gBAAgB;;;;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AACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as InvalidLiveQueryFactoryError } from "./errors-
|
|
1
|
+
import { c as InvalidLiveQueryFactoryError } from "./errors-qhcbUH6o.js";
|
|
2
2
|
import { n as remote_live_stream, t as RemoteLiveYield } from "./live-CHK0RrZu.js";
|
|
3
3
|
import { create_remote_transport_error } from "../remote/shared.js";
|
|
4
4
|
import { Effect, Stream } from "effect";
|
|
@@ -143,4 +143,4 @@ function read_live_status(resource) {
|
|
|
143
143
|
//#endregion
|
|
144
144
|
export { make_remote_live_stream as i, get_native_remote_live_resource as n, make_failed_remote_live_stream as r, Live as t };
|
|
145
145
|
|
|
146
|
-
//# sourceMappingURL=live-
|
|
146
|
+
//# sourceMappingURL=live-BW7xZKjb.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"live-BundLSoY.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/live.ts"],"sourcesContent":["import {\n\tRemoteLiveYield,\n\tremote_live_stream,\n\ttype RemoteLiveStreamCarrier,\n} from \"$/internal/live.ts\";\nimport { create_remote_transport_error } from \"$/remote/shared.ts\";\nimport { InvalidLiveQueryFactoryError } from \"$/errors.ts\";\nimport type { RemoteFailure } from \"$/remote/shared.ts\";\nimport { Effect, Stream } from \"effect\";\nimport { stringify } from \"devalue\";\n\nconst live_metadata: unique symbol = Symbol.for(\"ser.remote-live-metadata\") as never;\n\nconst live_operator: unique symbol = Symbol.for(\"ser.live-operator\") as never;\n\ntype RemoteLivePipe<A, E> = {\n\t(): RemoteLiveStream<A, E>;\n\t(ab: LiveFactory[\"status\"]): Stream.Stream<LiveStatus, never, never>;\n\t(ab: LiveFactory[\"reconnect\"]): Effect.Effect<void, RemoteFailure<E>, never>;\n\t<B>(ab: LiveFactory[\"status\"], bc: (_: Stream.Stream<LiveStatus, never, never>) => B): B;\n\t<B>(\n\t\tab: LiveFactory[\"reconnect\"],\n\t\tbc: (_: Effect.Effect<void, RemoteFailure<E>, never>) => B,\n\t): B;\n\t<B, C>(\n\t\tab: LiveFactory[\"status\"],\n\t\tbc: (_: Stream.Stream<LiveStatus, never, never>) => B,\n\t\tcd: (_: B) => C,\n\t): C;\n\t<B, C>(\n\t\tab: LiveFactory[\"reconnect\"],\n\t\tbc: (_: Effect.Effect<void, RemoteFailure<E>, never>) => B,\n\t\tcd: (_: B) => C,\n\t): C;\n\t<B>(\n\t\tab: (\n\t\t\t_: Stream.Stream<A, RemoteFailure<E>, never>,\n\t\t) => Stream.Stream<B, RemoteFailure<E>, never>,\n\t): RemoteLiveStream<B, E>;\n\t<B>(ab: (_: Stream.Stream<A, RemoteFailure<E>, never>) => B): B;\n\t<B, C>(ab: (_: Stream.Stream<A, RemoteFailure<E>, never>) => B, bc: (_: B) => C): C;\n\t<B, C, D>(\n\t\tab: (_: Stream.Stream<A, RemoteFailure<E>, never>) => B,\n\t\tbc: (_: B) => C,\n\t\tcd: (_: C) => D,\n\t): D;\n};\n\n/**\n * Stream returned by `Query.live` remote functions.\n *\n * @example\n * ```ts\n * const Time = GetTime();\n * const Label = Time.pipe(Stream.map((time) => time.toISOString()));\n * ```\n *\n * @since 3.4.8\n */\nexport type RemoteLiveStream<A, E = never> = Omit<\n\tStream.Stream<A, RemoteFailure<E>, never>,\n\t\"pipe\"\n> & {\n\treadonly [remote_live_stream]: true;\n\treadonly pipe: RemoteLivePipe<A, E>;\n};\n\n/**\n * Transport state exposed separately from the data stream.\n *\n * @example\n * ```ts\n * const Status = GetTime().pipe(Live.status);\n * ```\n *\n * @since 3.4.8\n */\nexport type LiveStatus =\n\t| {\n\t\t\treadonly _tag: \"Idle\";\n\t }\n\t| {\n\t\t\treadonly _tag: \"Connecting\";\n\t }\n\t| {\n\t\t\treadonly _tag: \"Open\";\n\t }\n\t| {\n\t\t\treadonly _tag: \"Failed\";\n\t\t\treadonly cause: unknown;\n\t }\n\t| {\n\t\t\treadonly _tag: \"Closed\";\n\t };\n\n/**\n * Public live stream control helpers.\n *\n * @example\n * ```ts\n * yield* GetNotifications().pipe(Live.reconnect);\n * ```\n *\n * @since 3.4.8\n */\nexport interface LiveFactory {\n\treadonly status: {\n\t\treadonly [live_operator]: true;\n\t\t/**\n\t\t * Creates a stream of transport status updates for a remote live stream.\n\t\t *\n\t\t * @example\n\t\t * ```ts\n\t\t * const Status = GetTime().pipe(Live.status);\n\t\t * ```\n\t\t *\n\t\t * @param stream - Remote live stream whose transport status should be read.\n\t\t * @returns A stream of transport status snapshots.\n\t\t */\n\t\t<A, E>(stream: RemoteLiveStream<A, E>): Stream.Stream<LiveStatus, never, never>;\n\t};\n\treadonly reconnect: {\n\t\treadonly [live_operator]: true;\n\t\t/**\n\t\t * Reconnects the transport behind a remote live stream.\n\t\t *\n\t\t * @example\n\t\t * ```ts\n\t\t * yield* GetNotifications().pipe(Live.reconnect);\n\t\t * ```\n\t\t *\n\t\t * @param stream - Remote live stream whose transport should reconnect.\n\t\t * @returns An Effect that completes after the reconnect request is sent.\n\t\t */\n\t\t<A, E>(stream: RemoteLiveStream<A, E>): Effect.Effect<void, RemoteFailure<E>, never>;\n\t};\n}\n\ntype NativeLiveResource<A> = {\n\treadonly connected?: boolean;\n\treadonly current?: A;\n\treadonly done?: boolean;\n\treadonly error?: unknown;\n\treadonly loading?: boolean;\n\treadonly ready?: boolean;\n\treadonly reconnect?: () => Promise<void> | void;\n\treadonly then?: PromiseLike<A>[\"then\"];\n\treadonly [Symbol.asyncIterator]?: () => AsyncIterator<A>;\n};\n\ntype LiveMetadata<A = unknown, ErrorType = never> = {\n\treadonly resource: NativeLiveResource<A>;\n\treadonly on_error: (error: unknown) => RemoteFailure<ErrorType>;\n};\n\ntype LiveMetadataCarrier = RemoteLiveStreamCarrier & {\n\treadonly [live_metadata]?: LiveMetadata<unknown, unknown>;\n};\n\ntype PipeableStream<A, E, R> = Stream.Stream<A, E, R> & {\n\treadonly pipe: (...args: readonly unknown[]) => unknown;\n};\n\nexport function make_remote_live_stream<A, ErrorType = never>(\n\tresource: unknown,\n\ton_error: (error: unknown) => RemoteFailure<ErrorType>,\n\tencode_snapshot: (value: unknown) => string = stringify,\n): RemoteLiveStream<A, ErrorType> {\n\tconst live_resource = as_native_live_resource<A>(resource);\n\tconst stream = make_live_stream(live_resource, on_error, encode_snapshot);\n\tconst metadata: LiveMetadata<A, ErrorType> = {\n\t\tresource: live_resource,\n\t\ton_error,\n\t};\n\n\treturn attach_live_metadata(stream, metadata) as RemoteLiveStream<A, ErrorType>;\n}\n\nfunction make_live_stream<A, ErrorType>(\n\tresource: NativeLiveResource<A> & AsyncIterable<A>,\n\ton_error: (error: unknown) => RemoteFailure<ErrorType>,\n\tencode_snapshot: (value: unknown) => string,\n): Stream.Stream<A, RemoteFailure<ErrorType>, never> {\n\tconst stream = Stream.fromAsyncIterable(resource, on_error);\n\tconst then = resource.then;\n\n\tif (typeof then !== \"function\") {\n\t\treturn stream;\n\t}\n\n\tconst initial_stream = Stream.fromAsyncIterable(\n\t\tmake_cached_live_iterable(resource, then, encode_snapshot),\n\t\ton_error,\n\t);\n\n\treturn Stream.unwrap(\n\t\tRemoteLiveYield.pipe(\n\t\t\tEffect.map((is_generated_yield) => (is_generated_yield ? initial_stream : stream)),\n\t\t),\n\t);\n}\n\nfunction make_cached_live_iterable<A>(\n\tresource: NativeLiveResource<A> & AsyncIterable<A>,\n\tthen: PromiseLike<A>[\"then\"],\n\tencode_snapshot: (value: unknown) => string,\n): AsyncIterable<A> {\n\treturn {\n\t\tasync *[Symbol.asyncIterator]() {\n\t\t\tconst initial_value = await resolve_live_initial_value(resource, then);\n\t\t\tlet is_first_snapshot = true;\n\n\t\t\tyield initial_value;\n\n\t\t\tfor await (const value of resource) {\n\t\t\t\t/** Native iterators usually replay their current snapshot before later updates. */\n\t\t\t\tif (is_first_snapshot) {\n\t\t\t\t\tis_first_snapshot = false;\n\n\t\t\t\t\tif (is_same_live_snapshot(initial_value, value, encode_snapshot)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tyield value;\n\t\t\t}\n\t\t},\n\t};\n}\n\nfunction is_same_live_snapshot(\n\tleft: unknown,\n\tright: unknown,\n\tencode_snapshot: (value: unknown) => string,\n): boolean {\n\tif (Object.is(left, right)) {\n\t\treturn true;\n\t}\n\n\ttry {\n\t\tconst left_encoded = encode_snapshot(left);\n\t\tconst right_encoded = encode_snapshot(right);\n\n\t\treturn left_encoded === right_encoded;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction resolve_live_initial_value<A>(\n\tresource: NativeLiveResource<A>,\n\tthen: PromiseLike<A>[\"then\"],\n): Promise<A> {\n\treturn new Promise<A>((resolve, reject) => {\n\t\tvoid then.call(resource, resolve, reject);\n\t});\n}\n\nexport function make_failed_remote_live_stream<A, ErrorType = never>(\n\terror: unknown,\n\ton_error: (error: unknown) => RemoteFailure<ErrorType>,\n): RemoteLiveStream<A, ErrorType> {\n\tconst failure = on_error(error);\n\tconst resource: NativeLiveResource<A> & AsyncIterable<A> = {\n\t\tconnected: false,\n\t\tdone: true,\n\t\terror: failure,\n\t\t[Symbol.asyncIterator]: () => ({\n\t\t\tnext: () => Promise.reject(failure),\n\t\t}),\n\t};\n\tconst metadata: LiveMetadata<A, ErrorType> = {\n\t\tresource,\n\t\ton_error,\n\t};\n\tconst stream = Stream.fail(failure);\n\n\treturn attach_live_metadata(stream, metadata) as unknown as RemoteLiveStream<A, ErrorType>;\n}\n\nconst LiveStatusStream = Object.assign(\n\tfunction status<A, E>(stream: RemoteLiveStream<A, E>): Stream.Stream<LiveStatus, never, never> {\n\t\treturn Stream.unwrap(\n\t\t\tEffect.sync(() => {\n\t\t\t\tconst metadata = get_live_metadata(stream);\n\n\t\t\t\tif (!metadata) {\n\t\t\t\t\treturn Stream.succeed({ _tag: \"Idle\" } as const);\n\t\t\t\t}\n\n\t\t\t\treturn Stream.succeed(read_live_status(metadata.resource)).pipe(\n\t\t\t\t\tStream.concat(\n\t\t\t\t\t\tStream.tick(\"250 millis\").pipe(\n\t\t\t\t\t\t\tStream.map(() => read_live_status(metadata.resource)),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}),\n\t\t);\n\t},\n\t{ [live_operator]: true as const },\n) satisfies LiveFactory[\"status\"];\n\nconst LiveReconnect = Object.assign(\n\tfunction reconnect<A, E>(\n\t\tstream: RemoteLiveStream<A, E>,\n\t): Effect.Effect<void, RemoteFailure<E>, never> {\n\t\treturn Effect.gen(function* () {\n\t\t\tconst metadata = get_live_metadata(stream);\n\t\t\tconst reconnect = metadata?.resource.reconnect;\n\n\t\t\tif (!metadata || typeof reconnect !== \"function\") {\n\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\tcreate_remote_transport_error(new InvalidLiveQueryFactoryError()),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tyield* Effect.tryPromise({\n\t\t\t\ttry: () => Promise.resolve(reconnect.call(metadata.resource)),\n\t\t\t\tcatch: metadata.on_error,\n\t\t\t});\n\t\t});\n\t},\n\t{ [live_operator]: true as const },\n) satisfies LiveFactory[\"reconnect\"];\n\n/**\n * Remote live transport helpers.\n *\n * @since 3.4.8\n */\nexport const Live: LiveFactory = {\n\tstatus: LiveStatusStream,\n\treconnect: LiveReconnect,\n};\n\nfunction as_native_live_resource<A>(resource: unknown): NativeLiveResource<A> & AsyncIterable<A> {\n\tif (!is_native_live_resource<A>(resource)) {\n\t\tthrow new InvalidLiveQueryFactoryError();\n\t}\n\n\treturn resource;\n}\n\nfunction is_native_live_resource<A>(\n\tresource: unknown,\n): resource is NativeLiveResource<A> & AsyncIterable<A> {\n\tconst resource_type = typeof resource;\n\n\tif (resource_type !== \"object\" && resource_type !== \"function\") {\n\t\treturn false;\n\t}\n\n\tif (resource === null) {\n\t\treturn false;\n\t}\n\n\treturn typeof (resource as NativeLiveResource<A>)[Symbol.asyncIterator] === \"function\";\n}\n\nfunction attach_live_metadata<A, E, R>(\n\tstream: Stream.Stream<A, E, R>,\n\tmetadata: LiveMetadata<unknown, unknown>,\n): Stream.Stream<A, E, R> {\n\tconst carrier = stream as Stream.Stream<A, E, R> & LiveMetadataCarrier;\n\n\tif (carrier[live_metadata]) {\n\t\treturn stream;\n\t}\n\n\tObject.defineProperty(carrier, live_metadata, {\n\t\tconfigurable: true,\n\t\tvalue: metadata,\n\t});\n\n\tObject.defineProperty(carrier, remote_live_stream, {\n\t\tconfigurable: true,\n\t\tvalue: true,\n\t});\n\n\tpropagate_live_metadata_through_pipe(carrier as PipeableStream<A, E, R>, metadata);\n\n\treturn stream;\n}\n\nfunction propagate_live_metadata_through_pipe<A, E, R>(\n\tstream: PipeableStream<A, E, R>,\n\tmetadata: LiveMetadata<unknown, unknown>,\n): void {\n\tconst pipe = stream.pipe.bind(stream);\n\n\tObject.defineProperty(stream, \"pipe\", {\n\t\tconfigurable: true,\n\t\tvalue: (...args: readonly unknown[]) => {\n\t\t\tconst result = pipe(...args);\n\n\t\t\tif (!Stream.isStream(result) || args.some(is_live_operator)) {\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\treturn attach_live_metadata(result, metadata);\n\t\t},\n\t});\n}\n\nfunction is_live_operator(value: unknown): boolean {\n\treturn (\n\t\ttypeof value === \"function\" &&\n\t\t(value as { readonly [live_operator]?: true })[live_operator] === true\n\t);\n}\n\nfunction get_live_metadata<A, E>(stream: RemoteLiveStream<A, E>): LiveMetadata<A, E> | undefined;\nfunction get_live_metadata(\n\tstream: Stream.Stream<unknown, unknown, unknown>,\n): LiveMetadata<unknown, unknown> | undefined;\nfunction get_live_metadata(\n\tstream: Stream.Stream<unknown, unknown, unknown>,\n): LiveMetadata<unknown, unknown> | undefined {\n\treturn (stream as LiveMetadataCarrier)[live_metadata];\n}\n\nexport function get_native_remote_live_resource(value: unknown): unknown | undefined {\n\tif (!Stream.isStream(value)) {\n\t\treturn undefined;\n\t}\n\n\treturn get_live_metadata(value)?.resource;\n}\n\nfunction read_live_status(resource: NativeLiveResource<unknown>): LiveStatus {\n\tif (resource.error !== undefined) {\n\t\treturn {\n\t\t\t_tag: \"Failed\",\n\t\t\tcause: resource.error,\n\t\t};\n\t}\n\n\tif (resource.done === true) {\n\t\treturn { _tag: \"Closed\" };\n\t}\n\n\tif (resource.connected === true) {\n\t\treturn { _tag: \"Open\" };\n\t}\n\n\treturn { _tag: \"Connecting\" };\n}\n"],"mappings":";;;;;;AAWA,MAAM,gBAA+B,OAAO,IAAI,0BAA0B;AAE1E,MAAM,gBAA+B,OAAO,IAAI,mBAAmB;AAsJnE,SAAgB,wBACf,UACA,UACA,kBAA8C,WACb;CACjC,MAAM,gBAAgB,wBAA2B,QAAQ;CAOzD,OAAO,qBANQ,iBAAiB,eAAe,UAAU,eAMxB,GAAG;EAJnC,UAAU;EACV;CAG0C,CAAC;AAC7C;AAEA,SAAS,iBACR,UACA,UACA,iBACoD;CACpD,MAAM,SAAS,OAAO,kBAAkB,UAAU,QAAQ;CAC1D,MAAM,OAAO,SAAS;CAEtB,IAAI,OAAO,SAAS,YACnB,OAAO;CAGR,MAAM,iBAAiB,OAAO,kBAC7B,0BAA0B,UAAU,MAAM,eAAe,GACzD,QACD;CAEA,OAAO,OAAO,OACb,gBAAgB,KACf,OAAO,KAAK,uBAAwB,qBAAqB,iBAAiB,MAAO,CAClF,CACD;AACD;AAEA,SAAS,0BACR,UACA,MACA,iBACmB;CACnB,OAAO,EACN,QAAQ,OAAO,iBAAiB;EAC/B,MAAM,gBAAgB,MAAM,2BAA2B,UAAU,IAAI;EACrE,IAAI,oBAAoB;EAExB,MAAM;EAEN,WAAW,MAAM,SAAS,UAAU;;GAEnC,IAAI,mBAAmB;IACtB,oBAAoB;IAEpB,IAAI,sBAAsB,eAAe,OAAO,eAAe,GAC9D;GAEF;GAEA,MAAM;EACP;CACD,EACD;AACD;AAEA,SAAS,sBACR,MACA,OACA,iBACU;CACV,IAAI,OAAO,GAAG,MAAM,KAAK,GACxB,OAAO;CAGR,IAAI;EAIH,OAHqB,gBAAgB,IAGnB,MAFI,gBAAgB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AGD,IAAI,SAAS,SAAS,MACrB,OAAO,EAAE,MAAM,SAAS;CAGzB,IAAI,SAAS,cAAc,MAC1B,OAAO,EAAE,MAAM,OAAO;CAGvB,OAAO,EAAE,MAAM,aAAa;AAC7B"}
|
|
1
|
+
{"version":3,"file":"live-BW7xZKjb.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/live.ts"],"sourcesContent":["import {\n\tRemoteLiveYield,\n\tremote_live_stream,\n\ttype RemoteLiveStreamCarrier,\n} from \"$/internal/live.ts\";\nimport { create_remote_transport_error } from \"$/remote/shared.ts\";\nimport { InvalidLiveQueryFactoryError } from \"$/errors.ts\";\nimport type { RemoteFailure } from \"$/remote/shared.ts\";\nimport { Effect, Stream } from \"effect\";\nimport { stringify } from \"devalue\";\n\nconst live_metadata: unique symbol = Symbol.for(\"ser.remote-live-metadata\") as never;\n\nconst live_operator: unique symbol = Symbol.for(\"ser.live-operator\") as never;\n\ntype RemoteLivePipe<A, E> = {\n\t(): RemoteLiveStream<A, E>;\n\t(ab: LiveFactory[\"status\"]): Stream.Stream<LiveStatus, never, never>;\n\t(ab: LiveFactory[\"reconnect\"]): Effect.Effect<void, RemoteFailure<E>, never>;\n\t<B>(ab: LiveFactory[\"status\"], bc: (_: Stream.Stream<LiveStatus, never, never>) => B): B;\n\t<B>(\n\t\tab: LiveFactory[\"reconnect\"],\n\t\tbc: (_: Effect.Effect<void, RemoteFailure<E>, never>) => B,\n\t): B;\n\t<B, C>(\n\t\tab: LiveFactory[\"status\"],\n\t\tbc: (_: Stream.Stream<LiveStatus, never, never>) => B,\n\t\tcd: (_: B) => C,\n\t): C;\n\t<B, C>(\n\t\tab: LiveFactory[\"reconnect\"],\n\t\tbc: (_: Effect.Effect<void, RemoteFailure<E>, never>) => B,\n\t\tcd: (_: B) => C,\n\t): C;\n\t<B>(\n\t\tab: (\n\t\t\t_: Stream.Stream<A, RemoteFailure<E>, never>,\n\t\t) => Stream.Stream<B, RemoteFailure<E>, never>,\n\t): RemoteLiveStream<B, E>;\n\t<B>(ab: (_: Stream.Stream<A, RemoteFailure<E>, never>) => B): B;\n\t<B, C>(ab: (_: Stream.Stream<A, RemoteFailure<E>, never>) => B, bc: (_: B) => C): C;\n\t<B, C, D>(\n\t\tab: (_: Stream.Stream<A, RemoteFailure<E>, never>) => B,\n\t\tbc: (_: B) => C,\n\t\tcd: (_: C) => D,\n\t): D;\n};\n\n/**\n * Stream returned by `Query.live` remote functions.\n *\n * @example\n * ```ts\n * const Time = GetTime();\n * const Label = Time.pipe(Stream.map((time) => time.toISOString()));\n * ```\n *\n * @since 3.4.8\n */\nexport type RemoteLiveStream<A, E = never> = Omit<\n\tStream.Stream<A, RemoteFailure<E>, never>,\n\t\"pipe\"\n> & {\n\treadonly [remote_live_stream]: true;\n\treadonly pipe: RemoteLivePipe<A, E>;\n};\n\n/**\n * Transport state exposed separately from the data stream.\n *\n * @example\n * ```ts\n * const Status = GetTime().pipe(Live.status);\n * ```\n *\n * @since 3.4.8\n */\nexport type LiveStatus =\n\t| {\n\t\t\treadonly _tag: \"Idle\";\n\t }\n\t| {\n\t\t\treadonly _tag: \"Connecting\";\n\t }\n\t| {\n\t\t\treadonly _tag: \"Open\";\n\t }\n\t| {\n\t\t\treadonly _tag: \"Failed\";\n\t\t\treadonly cause: unknown;\n\t }\n\t| {\n\t\t\treadonly _tag: \"Closed\";\n\t };\n\n/**\n * Public live stream control helpers.\n *\n * @example\n * ```ts\n * yield* GetNotifications().pipe(Live.reconnect);\n * ```\n *\n * @since 3.4.8\n */\nexport interface LiveFactory {\n\treadonly status: {\n\t\treadonly [live_operator]: true;\n\t\t/**\n\t\t * Creates a stream of transport status updates for a remote live stream.\n\t\t *\n\t\t * @example\n\t\t * ```ts\n\t\t * const Status = GetTime().pipe(Live.status);\n\t\t * ```\n\t\t *\n\t\t * @param stream - Remote live stream whose transport status should be read.\n\t\t * @returns A stream of transport status snapshots.\n\t\t */\n\t\t<A, E>(stream: RemoteLiveStream<A, E>): Stream.Stream<LiveStatus, never, never>;\n\t};\n\treadonly reconnect: {\n\t\treadonly [live_operator]: true;\n\t\t/**\n\t\t * Reconnects the transport behind a remote live stream.\n\t\t *\n\t\t * @example\n\t\t * ```ts\n\t\t * yield* GetNotifications().pipe(Live.reconnect);\n\t\t * ```\n\t\t *\n\t\t * @param stream - Remote live stream whose transport should reconnect.\n\t\t * @returns An Effect that completes after the reconnect request is sent.\n\t\t */\n\t\t<A, E>(stream: RemoteLiveStream<A, E>): Effect.Effect<void, RemoteFailure<E>, never>;\n\t};\n}\n\ntype NativeLiveResource<A> = {\n\treadonly connected?: boolean;\n\treadonly current?: A;\n\treadonly done?: boolean;\n\treadonly error?: unknown;\n\treadonly loading?: boolean;\n\treadonly ready?: boolean;\n\treadonly reconnect?: () => Promise<void> | void;\n\treadonly then?: PromiseLike<A>[\"then\"];\n\treadonly [Symbol.asyncIterator]?: () => AsyncIterator<A>;\n};\n\ntype LiveMetadata<A = unknown, ErrorType = never> = {\n\treadonly resource: NativeLiveResource<A>;\n\treadonly on_error: (error: unknown) => RemoteFailure<ErrorType>;\n};\n\ntype LiveMetadataCarrier = RemoteLiveStreamCarrier & {\n\treadonly [live_metadata]?: LiveMetadata<unknown, unknown>;\n};\n\ntype PipeableStream<A, E, R> = Stream.Stream<A, E, R> & {\n\treadonly pipe: (...args: readonly unknown[]) => unknown;\n};\n\nexport function make_remote_live_stream<A, ErrorType = never>(\n\tresource: unknown,\n\ton_error: (error: unknown) => RemoteFailure<ErrorType>,\n\tencode_snapshot: (value: unknown) => string = stringify,\n): RemoteLiveStream<A, ErrorType> {\n\tconst live_resource = as_native_live_resource<A>(resource);\n\tconst stream = make_live_stream(live_resource, on_error, encode_snapshot);\n\tconst metadata: LiveMetadata<A, ErrorType> = {\n\t\tresource: live_resource,\n\t\ton_error,\n\t};\n\n\treturn attach_live_metadata(stream, metadata) as RemoteLiveStream<A, ErrorType>;\n}\n\nfunction make_live_stream<A, ErrorType>(\n\tresource: NativeLiveResource<A> & AsyncIterable<A>,\n\ton_error: (error: unknown) => RemoteFailure<ErrorType>,\n\tencode_snapshot: (value: unknown) => string,\n): Stream.Stream<A, RemoteFailure<ErrorType>, never> {\n\tconst stream = Stream.fromAsyncIterable(resource, on_error);\n\tconst then = resource.then;\n\n\tif (typeof then !== \"function\") {\n\t\treturn stream;\n\t}\n\n\tconst initial_stream = Stream.fromAsyncIterable(\n\t\tmake_cached_live_iterable(resource, then, encode_snapshot),\n\t\ton_error,\n\t);\n\n\treturn Stream.unwrap(\n\t\tRemoteLiveYield.pipe(\n\t\t\tEffect.map((is_generated_yield) => (is_generated_yield ? initial_stream : stream)),\n\t\t),\n\t);\n}\n\nfunction make_cached_live_iterable<A>(\n\tresource: NativeLiveResource<A> & AsyncIterable<A>,\n\tthen: PromiseLike<A>[\"then\"],\n\tencode_snapshot: (value: unknown) => string,\n): AsyncIterable<A> {\n\treturn {\n\t\tasync *[Symbol.asyncIterator]() {\n\t\t\tconst initial_value = await resolve_live_initial_value(resource, then);\n\t\t\tlet is_first_snapshot = true;\n\n\t\t\tyield initial_value;\n\n\t\t\tfor await (const value of resource) {\n\t\t\t\t/** Native iterators usually replay their current snapshot before later updates. */\n\t\t\t\tif (is_first_snapshot) {\n\t\t\t\t\tis_first_snapshot = false;\n\n\t\t\t\t\tif (is_same_live_snapshot(initial_value, value, encode_snapshot)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tyield value;\n\t\t\t}\n\t\t},\n\t};\n}\n\nfunction is_same_live_snapshot(\n\tleft: unknown,\n\tright: unknown,\n\tencode_snapshot: (value: unknown) => string,\n): boolean {\n\tif (Object.is(left, right)) {\n\t\treturn true;\n\t}\n\n\ttry {\n\t\tconst left_encoded = encode_snapshot(left);\n\t\tconst right_encoded = encode_snapshot(right);\n\n\t\treturn left_encoded === right_encoded;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction resolve_live_initial_value<A>(\n\tresource: NativeLiveResource<A>,\n\tthen: PromiseLike<A>[\"then\"],\n): Promise<A> {\n\treturn new Promise<A>((resolve, reject) => {\n\t\tvoid then.call(resource, resolve, reject);\n\t});\n}\n\nexport function make_failed_remote_live_stream<A, ErrorType = never>(\n\terror: unknown,\n\ton_error: (error: unknown) => RemoteFailure<ErrorType>,\n): RemoteLiveStream<A, ErrorType> {\n\tconst failure = on_error(error);\n\tconst resource: NativeLiveResource<A> & AsyncIterable<A> = {\n\t\tconnected: false,\n\t\tdone: true,\n\t\terror: failure,\n\t\t[Symbol.asyncIterator]: () => ({\n\t\t\tnext: () => Promise.reject(failure),\n\t\t}),\n\t};\n\tconst metadata: LiveMetadata<A, ErrorType> = {\n\t\tresource,\n\t\ton_error,\n\t};\n\tconst stream = Stream.fail(failure);\n\n\treturn attach_live_metadata(stream, metadata) as unknown as RemoteLiveStream<A, ErrorType>;\n}\n\nconst LiveStatusStream = Object.assign(\n\tfunction status<A, E>(stream: RemoteLiveStream<A, E>): Stream.Stream<LiveStatus, never, never> {\n\t\treturn Stream.unwrap(\n\t\t\tEffect.sync(() => {\n\t\t\t\tconst metadata = get_live_metadata(stream);\n\n\t\t\t\tif (!metadata) {\n\t\t\t\t\treturn Stream.succeed({ _tag: \"Idle\" } as const);\n\t\t\t\t}\n\n\t\t\t\treturn Stream.succeed(read_live_status(metadata.resource)).pipe(\n\t\t\t\t\tStream.concat(\n\t\t\t\t\t\tStream.tick(\"250 millis\").pipe(\n\t\t\t\t\t\t\tStream.map(() => read_live_status(metadata.resource)),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}),\n\t\t);\n\t},\n\t{ [live_operator]: true as const },\n) satisfies LiveFactory[\"status\"];\n\nconst LiveReconnect = Object.assign(\n\tfunction reconnect<A, E>(\n\t\tstream: RemoteLiveStream<A, E>,\n\t): Effect.Effect<void, RemoteFailure<E>, never> {\n\t\treturn Effect.gen(function* () {\n\t\t\tconst metadata = get_live_metadata(stream);\n\t\t\tconst reconnect = metadata?.resource.reconnect;\n\n\t\t\tif (!metadata || typeof reconnect !== \"function\") {\n\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\tcreate_remote_transport_error(new InvalidLiveQueryFactoryError()),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tyield* Effect.tryPromise({\n\t\t\t\ttry: () => Promise.resolve(reconnect.call(metadata.resource)),\n\t\t\t\tcatch: metadata.on_error,\n\t\t\t});\n\t\t});\n\t},\n\t{ [live_operator]: true as const },\n) satisfies LiveFactory[\"reconnect\"];\n\n/**\n * Remote live transport helpers.\n *\n * @since 3.4.8\n */\nexport const Live: LiveFactory = {\n\tstatus: LiveStatusStream,\n\treconnect: LiveReconnect,\n};\n\nfunction as_native_live_resource<A>(resource: unknown): NativeLiveResource<A> & AsyncIterable<A> {\n\tif (!is_native_live_resource<A>(resource)) {\n\t\tthrow new InvalidLiveQueryFactoryError();\n\t}\n\n\treturn resource;\n}\n\nfunction is_native_live_resource<A>(\n\tresource: unknown,\n): resource is NativeLiveResource<A> & AsyncIterable<A> {\n\tconst resource_type = typeof resource;\n\n\tif (resource_type !== \"object\" && resource_type !== \"function\") {\n\t\treturn false;\n\t}\n\n\tif (resource === null) {\n\t\treturn false;\n\t}\n\n\treturn typeof (resource as NativeLiveResource<A>)[Symbol.asyncIterator] === \"function\";\n}\n\nfunction attach_live_metadata<A, E, R>(\n\tstream: Stream.Stream<A, E, R>,\n\tmetadata: LiveMetadata<unknown, unknown>,\n): Stream.Stream<A, E, R> {\n\tconst carrier = stream as Stream.Stream<A, E, R> & LiveMetadataCarrier;\n\n\tif (carrier[live_metadata]) {\n\t\treturn stream;\n\t}\n\n\tObject.defineProperty(carrier, live_metadata, {\n\t\tconfigurable: true,\n\t\tvalue: metadata,\n\t});\n\n\tObject.defineProperty(carrier, remote_live_stream, {\n\t\tconfigurable: true,\n\t\tvalue: true,\n\t});\n\n\tpropagate_live_metadata_through_pipe(carrier as PipeableStream<A, E, R>, metadata);\n\n\treturn stream;\n}\n\nfunction propagate_live_metadata_through_pipe<A, E, R>(\n\tstream: PipeableStream<A, E, R>,\n\tmetadata: LiveMetadata<unknown, unknown>,\n): void {\n\tconst pipe = stream.pipe.bind(stream);\n\n\tObject.defineProperty(stream, \"pipe\", {\n\t\tconfigurable: true,\n\t\tvalue: (...args: readonly unknown[]) => {\n\t\t\tconst result = pipe(...args);\n\n\t\t\tif (!Stream.isStream(result) || args.some(is_live_operator)) {\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\treturn attach_live_metadata(result, metadata);\n\t\t},\n\t});\n}\n\nfunction is_live_operator(value: unknown): boolean {\n\treturn (\n\t\ttypeof value === \"function\" &&\n\t\t(value as { readonly [live_operator]?: true })[live_operator] === true\n\t);\n}\n\nfunction get_live_metadata<A, E>(stream: RemoteLiveStream<A, E>): LiveMetadata<A, E> | undefined;\nfunction get_live_metadata(\n\tstream: Stream.Stream<unknown, unknown, unknown>,\n): LiveMetadata<unknown, unknown> | undefined;\nfunction get_live_metadata(\n\tstream: Stream.Stream<unknown, unknown, unknown>,\n): LiveMetadata<unknown, unknown> | undefined {\n\treturn (stream as LiveMetadataCarrier)[live_metadata];\n}\n\nexport function get_native_remote_live_resource(value: unknown): unknown | undefined {\n\tif (!Stream.isStream(value)) {\n\t\treturn undefined;\n\t}\n\n\treturn get_live_metadata(value)?.resource;\n}\n\nfunction read_live_status(resource: NativeLiveResource<unknown>): LiveStatus {\n\tif (resource.error !== undefined) {\n\t\treturn {\n\t\t\t_tag: \"Failed\",\n\t\t\tcause: resource.error,\n\t\t};\n\t}\n\n\tif (resource.done === true) {\n\t\treturn { _tag: \"Closed\" };\n\t}\n\n\tif (resource.connected === true) {\n\t\treturn { _tag: \"Open\" };\n\t}\n\n\treturn { _tag: \"Connecting\" };\n}\n"],"mappings":";;;;;;AAWA,MAAM,gBAA+B,OAAO,IAAI,0BAA0B;AAE1E,MAAM,gBAA+B,OAAO,IAAI,mBAAmB;AAsJnE,SAAgB,wBACf,UACA,UACA,kBAA8C,WACb;C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,UAAU;CAEhB,IAAI,QAAQ,gBACX,OAAO;CAGR,OAAO,eAAe,SAAS,eAAe;EAC7C,cAAc;EACd,OAAO;CACR,CAAC;CAED,OAAO,eAAe,SAAS,oBAAoB;EAClD,cAAc;EACd,OAAO;CACR,CAAC;CAED,qCAAqC,SAAoC,QAAQ;CAEjF,OAAO;AACR;AAEA,SAAS,qCACR,QACA,UACO;CACP,MAAM,OAAO,OAAO,KAAK,KAAK,MAAM;CAEpC,OAAO,eAAe,QAAQ,QAAQ;EACrC,cAAc;EACd,QAAQ,GAAG,SAA6B;GACvC,MAAM,SAAS,KAAK,GAAG,IAAI;GAE3B,IAAI,CAAC,OAAO,SAAS,MAAM,KAAK,KAAK,KAAK,gBAAgB,GACzD,OAAO;GAGR,OAAO,qBAAqB,QAAQ,QAAQ;EAC7C;CACD,CAAC;AACF;AAEA,SAAS,iBAAiB,OAAyB;CAClD,OACC,OAAO,UAAU,cAChB,MAA8C,mBAAmB;AAEpE;AAMA,SAAS,kBACR,QAC6C;CAC7C,OAAQ,OAA+B;AACxC;AAEA,SAAgB,gCAAgC,OAAqC;CACpF,IAAI,CAAC,OAAO,SAAS,KAAK,GACzB;CAGD,OAAO,kBAAkB,KAAK,CAAC,EAAE;AAClC;AAEA,SAAS,iBAAiB,UAAmD;CAC5E,IAAI,SAAS,UAAU,KAAA,GACtB,OAAO;EACN,MAAM;EACN,OAAO,SAAS;CACjB;CAGD,IAAI,SAAS,SAAS,MACrB,OAAO,EAAE,MAAM,SAAS;CAGzB,IAAI,SAAS,cAAc,MAC1B,OAAO,EAAE,MAAM,OAAO;CAGvB,OAAO,EAAE,MAAM,aAAa;AAC7B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as RuntimeAlreadyInitializedError, y as RequestEventUnavailableError } from "./errors-
|
|
2
|
-
import {
|
|
1
|
+
import { b as RuntimeAlreadyInitializedError, y as RequestEventUnavailableError } from "./errors-qhcbUH6o.js";
|
|
2
|
+
import { n as Dispatcher } from "./dispatcher-CTWINW5I.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-
|
|
93
|
+
//# sourceMappingURL=runtime-CPosEhGl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-
|
|
1
|
+
{"version":3,"file":"runtime-CPosEhGl.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,4 +1,4 @@
|
|
|
1
|
-
import { _ as RemoteHelperContextError, v as RemoteHelperError } from "./errors-
|
|
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
4
|
import { isHttpError, isRedirect, isValidationError } from "@sveltejs/kit";
|
|
@@ -141,4 +141,4 @@ function is_sveltekit_remote_context_error(err) {
|
|
|
141
141
|
//#endregion
|
|
142
142
|
export { encode_remote_failure as a, throw_remote_cause as i, run_remote_effect as n, throw_form_error as r, normalize_remote_helper_error as t };
|
|
143
143
|
|
|
144
|
-
//# sourceMappingURL=server-
|
|
144
|
+
//# sourceMappingURL=server-yQrNoiCR.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-BNrA1I-u.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/cause-codec.ts","../../../modules/svelte-effect-runtime/src/remote/server.ts"],"sourcesContent":["import { isHttpError, isRedirect, isValidationError } from \"@sveltejs/kit\";\nimport { is_form_error, type FormIssue } from \"$/remote/shared.ts\";\nimport { Cause, Schema } from \"effect\";\nimport { stringify } from \"devalue\";\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 };\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\treturn {\n\t\t_tag: \"RemoteFailure\",\n\t\tencoded: encode_remote_failure(cause),\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\tfor (const reason of cause.reasons) {\n\t\tif (!Cause.isFailReason(reason)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst failure = to_public_remote_failure(reason.error);\n\t\tconst encoded = stringify_failure(failure);\n\n\t\tif (encoded !== undefined) {\n\t\t\treturn encoded;\n\t\t}\n\t}\n\n\treturn stringify_unknown_remote_failure();\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) || isValidationError(value);\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_public_remote_failure(value: unknown): unknown {\n\tif (!has_public_remote_failure_tag(value)) {\n\t\treturn create_unknown_remote_failure();\n\t}\n\n\tconst serializable_failure = to_serializable_public_failure(value);\n\n\treturn serializable_failure ?? create_unknown_remote_failure();\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 { RemoteHelperContextError, RemoteHelperError } from \"$/errors.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): 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);\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): 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\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\terror(500, envelope);\n\t\t}\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":";;;;;;;AAwBA,SAAgB,sBAAsB,OAAoD;CACzF,MAAM,eAAe,4BAA4B,KAAK;CAEtD,IAAI,iBAAiB,KAAA,GACpB,OAAO;EACN,MAAM;EACN,OAAO;CACR;CAGD,IAAI,MAAM,kBAAkB,KAAK,GAChC,OAAO;EACN,MAAM;EACN;CACD;CAGD,MAAM,oBAAoB,uBAAuB,KAAK;CAEtD,IAAI,sBAAsB,KAAA,GACzB,OAAO;EACN,MAAM;EACN,QAAQ;CACT;CAGD,OAAO;EACN,MAAM;EACN,SAAS,sBAAsB,KAAK;CACrC;AACD;;AAGA,SAAgB,sBAAsB,OAAqC;CAC1E,KAAK,MAAM,UAAU,MAAM,SAAS;EACnC,IAAI,CAAC,MAAM,aAAa,MAAM,GAC7B;EAID,MAAM,UAAU,kBADA,yBAAyB,OAAO,KACR,CAAC;EAEzC,IAAI,YAAY,KAAA,GACf,OAAO;CAET;CAEA,OAAO,iCAAiC;AACzC;AAEA,SAAS,4BAA4B,OAAkD;CACtF,KAAK,MAAM,UAAU,MAAM,SAAS;EACnC,IAAI,CAAC,MAAM,YAAY,MAAM,GAC5B;EAGD,IAAI,0BAA0B,OAAO,MAAM,GAC1C,OAAO,OAAO;CAEhB;AAGD;AAEA,SAAS,uBAAuB,OAA+D;CAC9F,KAAK,MAAM,UAAU,MAAM,SAAS;EACnC,IAAI,CAAC,MAAM,aAAa,MAAM,GAC7B;EAGD,MAAM,SAAS,sBAAsB,OAAO,KAAK;EAEjD,IAAI,WAAW,KAAA,GACd,OAAO;CAET;AAGD;AAEA,SAAS,sBAAsB,OAAkD;CAChF,IAAI,cAAc,KAAK,GACtB,OAAO,MAAM;CAGd,OAAO,qBAAqB,KAAK,IAAI,CAAC,IAAI,KAAA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C9D;AAEA,SAAS,kCAAkC,KAA4B;CACtE,IAAI,EAAE,eAAe,QACpB,OAAO;CAGR,OACC,IAAI,QAAQ,WAAW,iCAAiC,KACxD,IAAI,YAAY;AAElB"}
|
|
1
|
+
{"version":3,"file":"server-yQrNoiCR.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/cause-codec.ts","../../../modules/svelte-effect-runtime/src/remote/server.ts"],"sourcesContent":["import { isHttpError, isRedirect, isValidationError } from \"@sveltejs/kit\";\nimport { is_form_error, type FormIssue } from \"$/remote/shared.ts\";\nimport { Cause, Schema } from \"effect\";\nimport { stringify } from \"devalue\";\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 };\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\treturn {\n\t\t_tag: \"RemoteFailure\",\n\t\tencoded: encode_remote_failure(cause),\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\tfor (const reason of cause.reasons) {\n\t\tif (!Cause.isFailReason(reason)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst failure = to_public_remote_failure(reason.error);\n\t\tconst encoded = stringify_failure(failure);\n\n\t\tif (encoded !== undefined) {\n\t\t\treturn encoded;\n\t\t}\n\t}\n\n\treturn stringify_unknown_remote_failure();\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) || isValidationError(value);\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_public_remote_failure(value: unknown): unknown {\n\tif (!has_public_remote_failure_tag(value)) {\n\t\treturn create_unknown_remote_failure();\n\t}\n\n\tconst serializable_failure = to_serializable_public_failure(value);\n\n\treturn serializable_failure ?? create_unknown_remote_failure();\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 { RemoteHelperContextError, RemoteHelperError } from \"$/errors.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): 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);\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): 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\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\terror(500, envelope);\n\t\t}\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":";;;;;;;AAwBA,SAAgB,sBAAsB,OAAoD;CACzF,MAAM,eAAe,4BAA4B,KAAK;CAEtD,IAAI,iBAAiB,KAAA,GACpB,OAAO;EACN,MAAM;EACN,OAAO;CACR;CAGD,IAAI,MAAM,kBAAkB,KAAK,GAChC,OAAO;EACN,MAAM;EACN;CACD;CAGD,MAAM,oBAAoB,uBAAuB,KAAK;CAEtD,IAAI,sBAAsB,KAAA,GACzB,OAAO;EACN,MAAM;EACN,QAAQ;CACT;CAGD,OAAO;EACN,MAAM;EACN,SAAS,sBAAsB,KAAK;CACrC;AACD;;AAGA,SAAgB,sBAAsB,OAAqC;CAC1E,KAAK,MAAM,UAAU,MAAM,SAAS;EACnC,IAAI,CAAC,MAAM,aAAa,MAAM,GAC7B;EAID,MAAM,UAAU,kBADA,yBAAyB,OAAO,KACR,CAAC;EAEzC,IAAI,YAAY,KAAA,GACf,OAAO;CAET;CAEA,OAAO,iCAAiC;AACzC;AAEA,SAAS,4BAA4B,OAAkD;CACtF,KAAK,MAAM,UAAU,MAAM,SAAS;EACnC,IAAI,CAAC,MAAM,YAAY,MAAM,GAC5B;EAGD,IAAI,0BAA0B,OAAO,MAAM,GAC1C,OAAO,OAAO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AAK,eACJ,QAAQ,GAAG,WAAW,MAAM;EAE7B,KAAK,iBAGJ,MAAM,KAFW,0CAA0C,WAAW,OAEpD,CAAC;CAErB;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"}
|
|
@@ -647,7 +647,7 @@ function collect_source_regions(source, ast) {
|
|
|
647
647
|
end
|
|
648
648
|
})),
|
|
649
649
|
...styles,
|
|
650
|
-
...ast.comments.map(({ start, end }) => ({
|
|
650
|
+
...(ast.comments ?? []).map(({ start, end }) => ({
|
|
651
651
|
start,
|
|
652
652
|
end
|
|
653
653
|
}))
|
|
@@ -1056,4 +1056,4 @@ function skip_block_comment(source, start) {
|
|
|
1056
1056
|
//#endregion
|
|
1057
1057
|
export { scan_svelte_effect_source as t };
|
|
1058
1058
|
|
|
1059
|
-
//# sourceMappingURL=source-scan-
|
|
1059
|
+
//# sourceMappingURL=source-scan-cSawCvsg.js.map
|