import { type MudletMap } from '../mapIO'; /** Context passed to a format's `parse` so it can key behaviour off the source. */ export interface MapFormatParseContext { /** Name of the file (or URL basename) the bytes came from. */ fileName: string; } /** * A map import/export format. Formats are codecs between raw file bytes and the * editor's canonical in-memory model (`MudletMap`). The renderer, commands and * reader all operate on `MudletMap`, so any format — a different `.dat` variant, * SQLite, JSON, plaintext, etc. — just needs to translate to and from it. * * The built-in {@link mudletDatFormat} handles Mudlet `.dat`. Plugins contribute * or replace formats via the `mapFormats` hook. */ export interface MapFormat { /** Stable identifier. Stored as the active format so saves round-trip. */ id: string; /** Human-readable label shown in the save-format chooser. */ label: string; /** * File extensions this format owns (leading dot, e.g. `['.dat']`). The first * entry is used as the default extension when saving. */ extensions: string[]; /** * `accept` attribute for the load file-picker. Defaults to `extensions` * joined with commas when omitted. */ accept?: string; /** * Decide whether this format handles a given filename. Defaults to a * case-insensitive suffix match against `extensions`. */ matches?(fileName: string): boolean; /** Parse raw file bytes into the canonical model. May be async. */ parse(bytes: ArrayBuffer, ctx: MapFormatParseContext): MudletMap | Promise; /** Serialize the canonical model back to file bytes. May be async. */ serialize(map: MudletMap): Uint8Array | Promise; } export declare const MUDLET_DAT_FORMAT_ID = "mudlet-dat"; /** Built-in Mudlet `.dat` binary format. Always the fallback if no plugin format matches. */ export declare const mudletDatFormat: MapFormat; /** The formats the core app ships with, before any plugin transforms. */ export declare const builtInFormats: MapFormat[]; /** Replace the active format list. Empty input falls back to the built-in format. */ export declare function setMapFormats(formats: MapFormat[]): void; export declare function getMapFormats(): MapFormat[]; export declare function getMapFormat(id: string | null | undefined): MapFormat | undefined; /** The format used when none is otherwise resolvable (first registered, or Mudlet `.dat`). */ export declare function defaultMapFormat(): MapFormat; /** The format that claims a filename, or `undefined` if none does (no fallback). */ export declare function matchFormatForFile(fileName: string): MapFormat | undefined; /** Like {@link matchFormatForFile} but falls back to {@link defaultMapFormat}. */ export declare function pickFormatForFile(fileName: string): MapFormat; /** Combined `accept` string for the load picker across every registered format. */ export declare function combinedAccept(): string;