import { BlobWriter, TextReader, Uint8ArrayReader, ZipWriter, } from "@zip.js/zip.js"; export async function createEpubFixture( options: { brokenLink?: boolean; activeContent?: boolean; compressedMimetype?: boolean; } = {}, ): Promise { const writer = new ZipWriter(new BlobWriter("application/epub+zip")); await writer.add("mimetype", new TextReader("application/epub+zip"), { level: options.compressedMimetype ? 6 : 0, }); await writer.add( "META-INF/container.xml", new TextReader( ``, ), ); await writer.add( "EPUB/package.opf", new TextReader( `urn:test:bookFixture BookenAda Example`, ), ); await writer.add( "EPUB/nav.xhtml", new TextReader( `Contents`, ), ); await writer.add( "EPUB/chapter.xhtml", new TextReader( `Opening chapter

Hello

Local reading.

${options.activeContent ? "
" : ""}Next`, ), ); await writer.add( "EPUB/cover.png", new Uint8ArrayReader( new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]), ), ); const blob = await writer.close(); return new File([blob], "fixture.epub", { type: "application/epub+zip" }); }