Files
pages/static/js/city-generator-worker.js
Anya Tokugawa c1175d389f Implement Knowledge City platform, organizer and DAV integration
Capture accumulated application, UI, CLI, regression tests and design documentation changes, including task project mapping and default CalDAV list naming.

Keep deployment data, backups, local credentials and build artifacts out of Git. Move the Compose enrollment token to an ignored local environment file.
2026-09-27 14:44:43 +09:00

19 lines
951 B
JavaScript

/* gen-city has synchronous internals; only this Worker may execute its bundle. */
'use strict';
importScripts('/static/vendor/city-generator/gen-city.bundle.js?v=1.4.6.2');
let busy = false;
self.onmessage = async event => {
if (busy) return;
const {id, key, width, height} = event.data || {};
if (!Number.isInteger(id) || typeof key !== 'string' || !key || key.length > 256 || !Number.isInteger(width) || !Number.isInteger(height) || width < 64 || width > 320 || height < 64 || height > 240) {
self.postMessage({id, error: 'Invalid City generation bounds'}); return;
}
busy = true;
try {
const fabric = await self.PagesWikiGenCity.generateFabric(key, width, height);
if (fabric.roads.length > 4096 || fabric.buildings.length > 4096) throw new Error('City geometry budget exceeded');
self.postMessage({id, fabric});
} catch (_) { self.postMessage({id, error: 'City generation failed'}); }
finally { busy = false; }
};