Add vpinball: a browser Visual Pinball player
Next.js app that plays real .vpx tables via @valknar/vpinball-wasm (WebAssembly Visual Pinball). Demo mode with the bundled default table, drag-and-drop custom table upload, a cabinet-styled UI with a coin-door HUD (fullscreen/stats/info/eject), a custom 404 page, PWA support (hand-rolled service worker), and a static Docker Compose deployment behind nginx. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012hQoM3jJT1Lx7CMTciMzvD
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env node
|
||||
// Bumps public/sw.js's CACHE_VERSION so a deploy invalidates old caches —
|
||||
// run this before cutting a release that changes the app shell or updates
|
||||
// the vendored vpinball-wasm engine build.
|
||||
import { readFile, writeFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const rootDir = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
||||
const swPath = path.join(rootDir, "public", "sw.js");
|
||||
|
||||
const contents = await readFile(swPath, "utf8");
|
||||
const match = contents.match(/CACHE_VERSION = "v(\d+)"/);
|
||||
if (!match) {
|
||||
console.error(`Couldn't find CACHE_VERSION in ${swPath}`);
|
||||
process.exit(1);
|
||||
}
|
||||
const next = Number(match[1]) + 1;
|
||||
const updated = contents.replace(/CACHE_VERSION = "v\d+"/, `CACHE_VERSION = "v${next}"`);
|
||||
await writeFile(swPath, updated);
|
||||
console.log(`Bumped service worker CACHE_VERSION to v${next}`);
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env node
|
||||
// Copies the vpinball-wasm engine's build output into public/vendor/vpinball-wasm/
|
||||
// so it's served as plain static files (see lib/pinball/usePinballInstance.ts for why:
|
||||
// the package's own loadPinball() does a dynamic import() of its glue script that must
|
||||
// never pass through webpack's module graph).
|
||||
import { cp, mkdir, rm } from "node:fs/promises";
|
||||
import { existsSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const rootDir = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
||||
const pkgDistDir = path.join(rootDir, "node_modules", "@valknar", "vpinball-wasm", "dist");
|
||||
const targetDir = path.join(rootDir, "public", "vendor", "vpinball-wasm");
|
||||
|
||||
if (!existsSync(pkgDistDir)) {
|
||||
console.error(
|
||||
`vpinball-wasm not found at ${pkgDistDir} — run "pnpm install" first.`,
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
await rm(targetDir, { recursive: true, force: true });
|
||||
await mkdir(targetDir, { recursive: true });
|
||||
await cp(pkgDistDir, targetDir, { recursive: true });
|
||||
|
||||
console.log(`Copied vpinball-wasm engine assets to ${path.relative(rootDir, targetDir)}/`);
|
||||
Reference in New Issue
Block a user