1/** Assemble the complete Pages upload after JS and native physics builds. */2const destination = "output/site";3for (4 const path of [5 "static/index.html",6 "static/ui.css",7 "static/dist/app.js",8 "static/dist/box3d.mjs",9 "static/dist/box3d.wasm",10 "assets/marble-kit.glb",11 ]12) {13 if (!(await Deno.stat(path)).isFile) {14 throw new Error(`Missing build file: ${path}`);15 }16}1718try {19 await Deno.remove(destination, { recursive: true });20} catch (error) {21 if (!(error instanceof Deno.errors.NotFound)) throw error;22}2324async function copyTree(source: string, target: string): Promise<void> {25 await Deno.mkdir(target, { recursive: true });26 for await (const entry of Deno.readDir(source)) {27 if (entry.name.startsWith(".")) continue;28 const from = `${source}/${entry.name}`;29 const to = `${target}/${entry.name}`;30 if (entry.isDirectory) await copyTree(from, to);31 else if (entry.isFile) await Deno.copyFile(from, to);32 }33}3435await copyTree("static", destination);36await copyTree("assets", `${destination}/assets`);37console.info(`Packaged site in ${destination}`);