Engine api
This commit is contained in:
@@ -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`);
|
||||
|
||||
Reference in New Issue
Block a user