- Modular block files: split into blocks-algo, blocks-data, blocks-proc - New modules: sections.js (labelled canvas areas), proc-browser.js (procedure tree modal), lib-loader.js (lazy library loading), templates.js (project templates), errno-data.js (errno table) - Test infrastructure: browser test suite (28 tests) and Node pure-function tests (75 tests) - Warning system: unified .block-warn for disconnected inputs, unconnected error hooks, and zero-exit-in-error-path - Error path highlighting: red flow paths and block borders for error-only subgraphs - Input hooks: hidden by default, shown during linking; outputs always at bottom - Block editor modal: pencil icon, colour picker for accent, compact field labels - Doc generation: standalone node script extracts JSDoc -> docs/API.md (124 declarations) - Persistence: save/restore sections, errno selection, block colours - Fixes: _segmentsIntersect bug, WCEnd crash from closest(this), drawpath guard on detached elements
43 lines
1013 B
JavaScript
43 lines
1013 B
JavaScript
const http = require("http");
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
|
|
const PORT = 3000;
|
|
const ROOT = __dirname;
|
|
|
|
const MIME = {
|
|
".html": "text/html",
|
|
".js": "application/javascript",
|
|
".json": "application/json",
|
|
".css": "text/css",
|
|
".svg": "image/svg+xml",
|
|
".png": "image/png",
|
|
".ico": "image/x-icon",
|
|
};
|
|
|
|
const server = http.createServer((req, res) => {
|
|
let filePath = path.join(ROOT, req.url === "/" ? "index.html" : req.url);
|
|
filePath = path.normalize(filePath);
|
|
|
|
if (!filePath.startsWith(ROOT)) {
|
|
res.writeHead(403);
|
|
return res.end("Forbidden");
|
|
}
|
|
|
|
const ext = path.extname(filePath);
|
|
const contentType = MIME[ext] || "application/octet-stream";
|
|
|
|
fs.readFile(filePath, (err, data) => {
|
|
if (err) {
|
|
res.writeHead(404);
|
|
return res.end("Not found");
|
|
}
|
|
res.writeHead(200, { "Content-Type": contentType });
|
|
res.end(data);
|
|
});
|
|
});
|
|
|
|
server.listen(PORT, () => {
|
|
console.log(`Server running at http://localhost:${PORT}/`);
|
|
});
|