// Resolve the browser-style specifiers the game uses ("three", "/assets/...", // "/vendor/...") to files on disk, and swap the DOM-bound PrototypeShell for // a headless one. Registered by host.mjs through module.register(). import { pathToFileURL } from 'node:url'; import path from 'node:path'; let config; export async function initialize(data) { config = data; } export async function resolve(specifier, context, next) { const { gameDir, threeModule, shellStub } = config; if (specifier === 'three' || specifier === '/vendor/three.module.js') { return { url: pathToFileURL(threeModule).href, shortCircuit: true }; } if (specifier === '/assets/user-interface/PrototypeShell.js' && !context.parentURL?.endsWith('shell-stub.mjs')) { return { url: pathToFileURL(shellStub).href, shortCircuit: true }; } if (specifier.startsWith('/assets/')) { return { url: pathToFileURL(path.join(gameDir, specifier)).href, shortCircuit: true }; } return next(specifier, context); }