SOURCE / PINNED RELEASE
Made of little things.
Outbreak: Soycoon City
- Release
- db7750b1d009…
- Author-recorded commit
- 3ee3f5fd27a6…
- License
- LICENSE
- Author’s source reference
- nostr://npub182jczunncwe0jn6frpqwq3e0qjws7yqqnc3auccqv9nte2dnd63scjm4rf/wss%3A%2F%2Fgit.napplet.soy%2F/n-b87c04571a9
Archive hash verified: dbebdc772b142a1c…. The source-to-build association is the author’s claim; it has not been independently rebuilt.
import ts from 'typescript';
import { readFile } from 'node:fs/promises';
import { runInNewContext } from 'node:vm';
export async function gameModule(path, dependencies = {}) {
const source = await readFile(new URL(path, import.meta.url), 'utf8');
const demo = JSON.parse(await readFile(new URL('../levels/demo.json', import.meta.url), 'utf8'));
const js = ts.transpileModule(source, { compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022 } }).outputText;
const m = { exports: {} };
runInNewContext(js, { module: m, exports: m.exports, require: name => name === '../levels/demo.json' ? { default: demo } : dependencies[name], structuredClone, console, URL, Blob, TextEncoder, TextDecoder, Uint8Array, setTimeout, clearTimeout });
return m.exports;
}
