mirror of
https://github.com/n30nex/CartoLite-Server.git
synced 2026-10-24 06:13:05 +00:00
* Add worldwide Terminal colour and font options with crisp network overlays * Resolve Terminal entry and CSS from the build manifest * Apply Terminal-specific defaults and preserve other view preferences * Keep smooth traffic on its canvas and diagnose hidden-route repaint * Synchronize route visibility and finish the still-frame handoff * Recover Terminal terrain graphics and retain clear scope and geography * Hold style writes during graphics recovery and rebuild retained overlays * Initialize map indexes before load consumers * Compare Terminal terrain pixels before and after context recovery * Release terrain resources before graphics context replacement * Map road paint to its independent Terminal colour * Keep terrain stacks cached across route visibility changes * Normalize bundled font licence whitespace
30 lines
1.9 KiB
JavaScript
30 lines
1.9 KiB
JavaScript
import { mkdir, readFile, writeFile, unlink, rmdir } 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 manifest = JSON.parse(await readFile('dist/.vite/manifest.json','utf8'));
|
|
const entry = manifest['src/terminal.ts'];
|
|
if(!entry?.isEntry || !/^assets\/[\w.-]+\.js$/.test(entry.file))throw new Error('Terminal entry missing from build manifest');
|
|
const visited=new Set(), css=new Set();
|
|
function collect(chunk) {
|
|
for(const id of chunk.imports??[]) { if(visited.has(id))continue;visited.add(id);if(!manifest[id])throw new Error('Missing Terminal import');collect(manifest[id]); }
|
|
for(const path of chunk.css??[]) {if(!/^assets\/[\w.-]+\.css$/.test(path))throw new Error('Invalid Terminal CSS');if(!html.includes(`href="/${path}"`))css.add(path);}
|
|
}
|
|
collect(entry);
|
|
if(!css.size)throw new Error('Terminal stylesheet missing');
|
|
const script = `<script type="module" src="/${entry.file}"></script>`;
|
|
const style = [...css].map(path=>`<link rel="stylesheet" href="/${path}">`).join('\n');
|
|
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);
|
|
// This manifest is build input, not a new public endpoint.
|
|
await unlink('dist/.vite/manifest.json');
|
|
await rmdir('dist/.vite');
|