mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 14:07:43 +00:00
fcf3a645db
Drives the built web page in a real Chrome (channel:'chrome', so no `playwright install`): waits for wgpu init, then asserts an orbit drag changes the composited canvas — one check that simultaneously proves the scene rendered, mouse input is wired, and the log overlay isn't eating events — and that zero uncaptured WebGPU errors were logged. Every web bring-up bug so far (blank render, error-buffer cascade, overlay swallowing input) is this shape; this would have caught them. serve.mjs statically serves build-web; the config launches headed against the real GPU (--use-angle=vulkan + --ignore-gpu-blocklist are load-bearing for a non-null adapter on Linux Chrome). node_modules and results are gitignored. See README.md to run. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
41 lines
1.6 KiB
JavaScript
41 lines
1.6 KiB
JavaScript
// Minimal static file server for the Emscripten build output. WebGPU
|
|
// needs a real http(s) origin (not file://), so the smoke test serves
|
|
// the build-web directory over localhost. No COOP/COEP headers yet —
|
|
// pthreads are off in the current web build (that's task #47).
|
|
//
|
|
// Serve dir resolution: $WEB_BUILD_DIR if set, else the repo's build-web.
|
|
import http from 'node:http';
|
|
import { readFile } from 'node:fs/promises';
|
|
import { fileURLToPath } from 'node:url';
|
|
import path from 'node:path';
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
const ROOT = process.env.WEB_BUILD_DIR
|
|
? path.resolve(process.env.WEB_BUILD_DIR)
|
|
: path.resolve(__dirname, '../../../build-web');
|
|
const PORT = Number(process.env.PORT || 8124);
|
|
|
|
const MIME = {
|
|
'.html': 'text/html; charset=utf-8',
|
|
'.js': 'text/javascript; charset=utf-8',
|
|
'.mjs': 'text/javascript; charset=utf-8',
|
|
'.wasm': 'application/wasm',
|
|
'.ifcview': 'application/octet-stream',
|
|
};
|
|
|
|
http.createServer(async (req, res) => {
|
|
try {
|
|
const url = new URL(req.url, `http://localhost:${PORT}`);
|
|
let p = decodeURIComponent(url.pathname);
|
|
if (p === '/') p = '/IfcViewerWeb.html';
|
|
const file = path.join(ROOT, p);
|
|
// Contain to ROOT.
|
|
if (!file.startsWith(ROOT)) { res.writeHead(403).end(); return; }
|
|
const body = await readFile(file);
|
|
res.writeHead(200, { 'Content-Type': MIME[path.extname(file)] || 'application/octet-stream' });
|
|
res.end(body);
|
|
} catch {
|
|
res.writeHead(404).end('not found');
|
|
}
|
|
}).listen(PORT, () => console.log(`serving ${ROOT} on http://localhost:${PORT}`));
|