// Builds the web client's first-launch example pack from the same demo // workspace the server seed uses (seed-content.ts), in the file-pack format // the web app exports and imports (apps/web/src/lib/sync/filePack.ts). // Run with: npm run make:example-pack. import fs from 'node:fs'; import path from 'node:path'; import { zipSync } from 'fflate'; import { buildSeedContent } from './seed-content'; const TARGET = path.resolve(__dirname, '..', '..', '..', 'web', 'web-client', 'example-pack.zip'); async function main(): Promise { const content = await buildSeedContent(); const files: Record = {}; const docs = new Map([ ['workspace', content.workspace.export({ mode: 'snapshot' })], ['attempts', content.attempts.export({ mode: 'snapshot' })], ]); for (const [docId, doc] of content.annDocs) docs.set(docId, doc.export({ mode: 'snapshot' })); for (const [docId, bytes] of docs) files[`docs/${encodeURIComponent(docId)}.snapshot`] = bytes; for (const blob of content.blobs) files[`blobs/${blob.hash}`] = new Uint8Array(blob.bytes); const manifest = { version: 1, docs: [...docs.keys()], blobs: content.blobs.map((b) => b.hash), }; files['manifest.json'] = new TextEncoder().encode(JSON.stringify(manifest)); fs.writeFileSync(TARGET, zipSync(files)); console.log(`✅ wrote ${TARGET} (${docs.size} docs, ${content.blobs.length} blobs)`); } void main();