import { Context, Effect, Schema } from "effect" import type { ExportSettings } from "./settings" // ---- errors ---- export class EncodeError extends Schema.TaggedErrorClass()("EncodeError", { message: Schema.String, cause: Schema.optional(Schema.Unknown), }) {} // ---- service ---- export interface ImageEncoderShape { /** * Encode an RGBA `ImageData` frame to the requested format/settings, * downscaling first when the scale is below 100%. Platform-neutral bytes * out — the caller picks the Blob/mime. */ readonly encode: (input: { readonly image: ImageData readonly settings: ExportSettings }) => Effect.Effect } /** * The export encoder. The engine defines the contract; the implementation * is swappable behind this service — jSquash wasm codecs (the default * layer), native encoders, or a server round-trip (see * docs/adr/0006-image-encoder-engine-service.md). */ export class ImageEncoder extends Context.Service()( "ImageEncoder", ) {}