Spaces:
Running
Running
| /* Regenerate standalone.html by inlining style.css + engine.js + app.js into | |
| index.html (README: standalone.html must never be edited directly). */ | |
| ; | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| const here = (f) => path.join(__dirname, f); | |
| const read = (f) => fs.readFileSync(here(f), 'utf8'); | |
| let html = read('index.html'); | |
| const inline = (needle, replacement) => { | |
| if (!html.includes(needle)) throw new Error('index.html missing: ' + needle); | |
| html = html.replace(needle, () => replacement); | |
| }; | |
| inline('<link rel="stylesheet" href="style.css">', | |
| '<style>\n' + read('style.css') + '</style>'); | |
| inline('<script src="engine.js"></script>', | |
| '<script>\n' + read('engine.js') + '</script>'); | |
| inline('<script src="app.js"></script>', | |
| '<script>\n' + read('app.js') + '</script>'); | |
| inline('<script src="llm/observe.js"></script>', | |
| '<script>\n' + read('llm/observe.js') + '</script>'); | |
| inline('<script src="llm/providers.js"></script>', | |
| '<script>\n' + read('llm/providers.js') + '</script>'); | |
| inline('<script src="llm/spectate.js"></script>', | |
| '<script>\n' + read('llm/spectate.js') + '</script>'); | |
| fs.writeFileSync(here('standalone.html'), html); | |
| console.log('standalone.html regenerated (' + html.length + ' bytes)'); | |