mirror of
https://github.com/n30nex/CartoLite-Server.git
synced 2026-10-23 15:02:46 +00:00
* Add live BBS Terminal view * Type terminal paint restoration and cover deployed browser view * Keep Terminal boot assets off other views and include page in images * Isolate Terminal assets and sample map graphics asynchronously * Preserve appearance through Terminal fallback and type sampled pixels * Use public layer ordering and suspend idle Terminal capture * Render Terminal geography on the GPU without pixel readback * Keep label painting separate from map paint settings * Harden glyph state and avoid packet-canvas readback stalls
19 lines
1.3 KiB
JavaScript
19 lines
1.3 KiB
JavaScript
import { mkdir, readFile, readdir, writeFile } from 'node:fs/promises';
|
|
|
|
// Reuse the Map document and its exact asset graph. A second bundled Map entry
|
|
// would move MapLibre into shared chunks also downloaded by Netgraph.
|
|
const html = await readFile('dist/index.html', 'utf8');
|
|
const assets = (await readdir('dist/assets')).filter(name => /^terminal-.*\.(?:js|css)$/.test(name));
|
|
if (assets.filter(name => name.endsWith('.js')).length !== 1 || assets.filter(name => name.endsWith('.css')).length !== 1) throw new Error('Terminal entry assets missing or ambiguous');
|
|
const script = `<script type="module" src="/assets/${assets.find(name => name.endsWith('.js'))}"></script>`;
|
|
const style = `<link rel="stylesheet" href="/assets/${assets.find(name => name.endsWith('.css'))}">`;
|
|
const terminal = html.replace('<html lang="en">', '<html lang="en" data-terminal="true">')
|
|
.replace('<head>', `<head>\n${script}`)
|
|
.replace('</head>', `${style}\n</head>`)
|
|
.replace(/<title>(.*?)<\/title>/, '<title>Terminal · $1</title>')
|
|
.replace('aria-label="CartoLite live map"', 'aria-label="CartoLite Terminal live map"')
|
|
.replace(/(rel="canonical" href="https:\/\/[^"/]+)\//, '$1/terminal/')
|
|
.replace(/(property="og:url" content="https:\/\/[^"/]+)\//, '$1/terminal/');
|
|
await mkdir('dist/terminal', { recursive: true });
|
|
await writeFile('dist/terminal/index.html', terminal);
|