Engine api

This commit is contained in:
2026-10-06 20:27:17 -03:00
parent d13938550d
commit 69c5c187db
27 changed files with 1026 additions and 90 deletions
+14
View File
@@ -19,6 +19,7 @@ import {
} from "$/common/mod_data.ts";
import { check_references, load_order, type LoadedMod, type ModReport } from "$/common/mod_check.ts";
import { png_size, texture_size_problem } from "$/common/bmod.ts";
import { dirname } from "@std/path";
export { load_order, type LoadedMod, type ModReport };
@@ -98,6 +99,19 @@ function load_mod(mods_dir: string, id: string): LoadedMod {
error(`manifest.json: scripts.${side} ${path} doesn't exist`);
}
}
// bworld/engine needs engine_access, it's checked again on the bundled code when a .bmod loads
if (mod.manifest?.engine_access !== true) {
const folders = new Set(Object.values(scripts).filter((p) => typeof p === "string").map((p) => dirname(p)));
for (const folder of folders) {
for (const file of [...walk(`${dir}/${folder}`, ".ts"), ...walk(`${dir}/${folder}`, ".js")]) {
if (/["']bworld\/engine["']/.test(Deno.readTextFileSync(`${dir}/${folder}/${file}`))) {
error(
`${folder}/${file} imports bworld/engine, which needs "engine_access": true in manifest.json`,
);
}
}
}
}
const credits = mod.manifest?.credits;
if (typeof credits === "string" && !exists(`${dir}/${credits}`)) {
error(`manifest.json: credits ${credits} doesn't exist`);