import JSZip from 'jszip' export type BuildZipInput = { html: string css: string js: string assets?: Record } export async function buildZip(input: BuildZipInput): Promise { const zip = new JSZip() zip.file('index.html', input.html) zip.file('styles.css', input.css) zip.file('app.js', input.js) if (input.assets) { for (const [path, bytes] of Object.entries(input.assets)) { // In Node/Vitest, use Buffer for robust binary handling const buf = Buffer.from(bytes) zip.file(path, buf as unknown as Buffer) } } const content = await zip.generateAsync({ type: 'uint8array' }) return content }