/* Builds desktop/site: a self-contained copy of just the OBI-1 page. Only the files obi.html references are copied. The nav is trimmed to the theme toggle (no links to pages that aren't bundled) and the Web Serial shim is injected so native serialport works through the OBI code. */ import { cp, mkdir, readFile, rm, writeFile } from 'node:fs/promises'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const ROOT = path.resolve(__dirname, '..', '..'); const SITE = path.join(__dirname, '..', 'site'); const CSS_FILES = ['style.css', 'tool.css']; const JS_FILES = ['theme.js', 'reveal.js', 'common.js', 'obi.js']; await rm(SITE, { recursive: true, force: true }); await mkdir(path.join(SITE, 'css'), { recursive: true }); await mkdir(path.join(SITE, 'js', 'modules'), { recursive: true }); await mkdir(path.join(SITE, 'js', 'interfaces'), { recursive: true }); /* ---- obi.html, transformed for the desktop bundle ---- */ const source = await readFile(path.join(ROOT, 'obi.html'), 'utf8'); let html = source; html = html.replace( '', '\n ' ); html = html.replace( '', '' ); html = html.replace( /(