Deno compile

This commit is contained in:
2026-11-22 18:47:49 -03:00
parent 25937f2c31
commit ed6f5fe0df
3 changed files with 26 additions and 8 deletions
+2 -1
View File
@@ -9,7 +9,8 @@
"pack-mod": "deno run --allow-read --allow-write --allow-run --allow-env tools/pack_mod.ts", "pack-mod": "deno run --allow-read --allow-write --allow-run --allow-env tools/pack_mod.ts",
"test": "deno test --allow-read --allow-write --allow-run --allow-net tests/", "test": "deno test --allow-read --allow-write --allow-run --allow-net tests/",
"bench": "deno bench --allow-read --allow-write --allow-run tests/", "bench": "deno bench --allow-read --allow-write --allow-run tests/",
"desktop": "deno run --unstable-webgpu --allow-read --allow-write --allow-net --allow-ffi --allow-env=CUBI_SERVER,CUBI_CLIENT_UPDATES,HOME,USERPROFILE,APPDATA,XDG_DATA_HOME desktop/main.ts" "desktop": "deno run --unstable-webgpu --allow-read --allow-write --allow-net --allow-ffi --allow-env=CUBI_SERVER,CUBI_CLIENT_UPDATES,HOME,USERPROFILE,APPDATA,XDG_DATA_HOME desktop/main.ts",
"compile": "deno run -A build.ts --once && deno compile --unstable-webgpu --allow-read --allow-write --allow-net --allow-ffi --allow-env=CUBI_SERVER,CUBI_CLIENT_UPDATES,HOME,USERPROFILE,APPDATA,XDG_DATA_HOME --include build --include server_mods --include server/game/worker.ts --include server/game/worldgen_worker.ts --include server/content_worker.ts --include desktop/config.json --output dist/cubi desktop/main.ts"
}, },
"compilerOptions": { "compilerOptions": {
"lib": ["dom", "dom.asynciterable", "dom.iterable", "deno.ns", "deno.unstable", "deno.webgpu"] "lib": ["dom", "dom.asynciterable", "dom.iterable", "deno.ns", "deno.unstable", "deno.webgpu"]
+21 -3
View File
@@ -26,11 +26,28 @@ try {
console.error(`No sound: ${(e as Error).message}`); console.error(`No sound: ${(e as Error).message}`);
} }
const app = desktop_app((message) => { // the app can't go on. it says why in a message box, a packaged app has no terminal to read it in
function fail(message: string) {
console.error(message); console.error(message);
game_window.show_error("bworld", `The singleplayer world stopped: ${message}`); game_window.set_grabbed(false);
game_window.show_error("bworld", message);
audio?.close();
game_window.close();
Deno.exit(1); Deno.exit(1);
}
// an error nothing caught, even a throw while starting, ends the app through fail. ending deno with it instead unloads
// openal while its thread still plays, which crashes before the error is printed
addEventListener("error", (event) => {
event.preventDefault();
fail(String(event.error?.stack ?? event.message));
}); });
addEventListener("unhandledrejection", (event) => {
event.preventDefault();
fail(String(event.reason?.stack ?? event.reason));
});
const app = desktop_app((message) => fail(`The singleplayer world stopped: ${message}`));
const server = Deno.serve( const server = Deno.serve(
{ hostname: "127.0.0.1", port: 0, onListen() {} }, { hostname: "127.0.0.1", port: 0, onListen() {} },
@@ -65,7 +82,8 @@ async function start_client(page: URL) {
}); });
worker.onmessage = (event: MessageEvent<ClientMessage>) => handle(event.data); worker.onmessage = (event: MessageEvent<ClientMessage>) => handle(event.data);
worker.onerror = (event) => { worker.onerror = (event) => {
console.error(`The client stopped: ${event.message}`); event.preventDefault();
fail(`The client stopped: ${event.message}`);
}; };
client = worker; client = worker;
send({ send({
+3 -4
View File
@@ -431,7 +431,6 @@ saved before any of this plays exactly the same.
- **Importing Minecraft's terrain.** Datapacks' noise settings assume a world from -64 to 320 and Minecraft's noises. - **Importing Minecraft's terrain.** Datapacks' noise settings assume a world from -64 to 320 and Minecraft's noises.
The formats are close enough that an importer could translate them, but the result wouldn't look like Minecraft's. Not The formats are close enough that an importer could translate them, but the result wouldn't look like Minecraft's. Not
a goal for now. a goal for now.
- **Generation's loose ends.** The desktop app isn't packaged yet, and a package will need the worldgen worker in it. In - **Generation's loose ends.** In a world without land, the spawn search looks 32 chunks out on the game thread, which
a world without land, the spawn search looks 32 chunks out on the game thread, which the server now does at startup. the server now does at startup. Saved chunks are read on the game thread, which waits for the host (see `read_chunk`
Saved chunks are read on the game thread, which waits for the host (see `read_chunk` in `server/game/worker.ts`): much in `server/game/worker.ts`): much faster than generating them, but Minecraft reads them ahead instead.
faster than generating them, but Minecraft reads them ahead instead.