pcbjam/site/public/gerber-demo/index.html
Viktor Vaczi 57f1f53d26 feat: lazily-loaded Gerber viewer demo in the blog, served from R2
Embed KiCad's gerbview WASM in the graphics-to-WebGL blog post as a
click-to-load demo that opens the tiny_tapeout board entirely in-browser.

- GerberDemo.astro: lazy iframe embed + cross-origin-isolation reload guard
  + WebGL2/SharedArrayBuffer feature-detect with a poster fallback
- public/gerber-demo/{index.html,boot.js}: self-contained gerbview boot
  harness (config seed, MEMFS board preload, argv auto-open)
- board/ tiny_tapeout layers + poster.png committed; wasm/ glue JS committed
  (served same-origin — pthread worker can't be cross-origin), while
  gerbview.wasm + kicad-resources.bin are git-ignored and served from
  Cloudflare R2 (assets.pcbjam.com)
- COOP/COEP require-corp scoped to the post + /gerber-demo routes
  (dev: astro.config.mjs + middleware.ts; prod: vercel.json)
- post converted to MDX (@astrojs/mdx) so it can embed the component
- scripts/: sync-demo-wasm.sh, r2-deploy.sh, r2-cors.json

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 10:28:06 +02:00

89 lines
2.3 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>PCBJam — Gerber viewer demo</title>
<style>
html,
body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
overflow: hidden;
background: #0b1020;
}
/* The canvas must have no border/padding or mouse coords go wrong. */
.emscripten {
padding-right: 0;
margin-left: auto;
margin-right: auto;
display: block;
}
div.emscripten {
text-align: center;
}
canvas.emscripten {
border: 0px none;
}
/* wxWidgets-DOM per-window overlays (created by wx.js, appended to
#window-container). Mirror the proven harness exactly. */
.window {
position: absolute;
pointer-events: none;
z-index: 10;
background-color: black;
overflow: hidden;
width: 0;
height: 0;
}
.window-canvas {
position: absolute;
top: 0;
left: 0;
pointer-events: none;
}
#status {
position: fixed;
left: 12px;
bottom: 12px;
z-index: 1000;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 12px;
color: #e7ecf5;
background: rgba(11, 16, 32, 0.85);
border: 1px solid #233052;
padding: 8px 10px;
border-radius: 8px;
}
#progress {
width: 240px;
height: 6px;
margin-top: 6px;
background: #233052;
border-radius: 3px;
overflow: hidden;
}
#progress-bar {
height: 100%;
width: 0%;
background: #4f7cff;
transition: width 0.25s;
}
</style>
</head>
<body>
<div
id="main-window"
style="width: 100vw; height: 100vh; position: absolute; top: 0; left: 0"
></div>
<div id="window-container"></div>
<div id="status">
<div id="status-text">Initializing…</div>
<div id="progress"><div id="progress-bar"></div></div>
</div>
<!-- Classic script (not a module): the WASM glue needs global Module / mainWindow / FS. -->
<script src="./boot.js"></script>
</body>
</html>