#!/usr/bin/env node // Copies the dropflow wasm bundle and the Inter TTFs into apps/web/public // so the browser can fetch them. Run with `pnpm prepare:web-assets`. // // Uses require.resolve so the dropflow lookup works across npm/pnpm/yarn // without hardcoding node_modules/.pnpm paths. import { mkdir, copyFile } from 'node:fs/promises'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { createRequire } from 'node:module'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const repoRoot = path.resolve(__dirname, '..'); // dropflow is a dep of @banner-studio/layout-engine, not the root package, so // resolve relative to that package's location. const require = createRequire( path.join(repoRoot, 'packages', 'layout-engine', 'package.json') ); const publicDir = path.join(repoRoot, 'apps', 'web', 'public'); const fontsDir = path.join(publicDir, 'fonts'); async function main() { await mkdir(publicDir, { recursive: true }); await mkdir(fontsDir, { recursive: true }); // dropflow wasm: resolve via an exported subpath, then walk to dropflow.wasm // (which is also in `exports` as ./dropflow.wasm — resolve it directly). const wasmSrc = require.resolve('dropflow/dropflow.wasm'); const wasmDst = path.join(publicDir, 'dropflow.wasm'); await copyFile(wasmSrc, wasmDst); console.log(`copied dropflow.wasm -> ${path.relative(repoRoot, wasmDst)}`); // Inter TTFs from infra/fonts. for (const file of ['Inter-Regular.ttf', 'Inter-Bold.ttf']) { const src = path.join(repoRoot, 'infra', 'fonts', file); const dst = path.join(fontsDir, file); await copyFile(src, dst); console.log(`copied ${file} -> ${path.relative(repoRoot, dst)}`); } } main().catch((err) => { console.error(err); process.exit(1); });