Skip to content

Prerender

Prerender wraps SvelteKit prerender(...) and returns an Effect-backed callable remote.

ts
import { Prerender } from "svelte-effect-runtime";

Signatures

ts
type RemotePrerenderInputsGenerator<Input> =
  (event: RequestEventService) => AsyncIterable<Input> | Iterable<Input>;
ts
type EffectPrerenderFunction<Input, Output, Error = never> =
  ((arg: OptionalArgument<Input>) =>
    Effect.Effect<Output, RemoteFailure<Error>, never>) & {
      native: RemotePrerenderFunction<Input, Output>;
    };
ts
interface EffectPrerenderFactory {
  <Output, ErrorType, Requirements>(
    fn: () => Effect.Effect<Output, ErrorType, Requirements>,
    options?: {
      inputs?: RemotePrerenderInputsGenerator<void>;
      dynamic?: boolean;
    }
  ): EffectPrerenderFunction<void, Output, ErrorType>;

  <Input, Output, ErrorType, Requirements>(
    validate: "unchecked",
    fn: (arg: Input) => Effect.Effect<Output, ErrorType, Requirements>,
    options?: {
      inputs?: RemotePrerenderInputsGenerator<Input>;
      dynamic?: boolean;
    }
  ): EffectPrerenderFunction<Input, Output, ErrorType>;

  <SchemaType extends EffectSchema, Output, ErrorType, Requirements>(
    validate: SchemaType,
    fn: (arg: SchemaOutput<SchemaType>) =>
      Effect.Effect<Output, ErrorType, Requirements>,
    options?: {
      inputs?: RemotePrerenderInputsGenerator<SchemaInput<SchemaType>>;
      dynamic?: boolean;
    }
  ): EffectPrerenderFunction<SchemaInput<SchemaType>, Output, ErrorType>;
}

BSD-3-Clause