feat: improve RenPy conversion and support MIST runtime
CI / frontend (push) Failing after 15s
CI / backend (push) Failing after 37s

This commit is contained in:
mrleo1nid committed 2026-10-25 23:16:33 +03:00
1 parent f7f7f5b1b3
commit f9eb5c1212
44 files changed
+2822 -174

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
import { fileURLToPath } from "node:url";
import { build } from "esbuild";
import { parseHTML } from "linkedom";
const bundle = await build({ entryPoints: [fileURLToPath(new URL("../../src/player/engine.ts", import.meta.url))],
bundle: true, write: false, format: "esm", platform: "node", logLevel: "silent" });
const { Engine } = await import(`data:text/javascript;base64,${Buffer.from(bundle.outputFiles[0].text).toString("base64")}`);
Error.stackTraceLimit = 2; // data-URL bundle frames otherwise print the entire bundle on a failure.
export function makeEngine(runtime) {
const { window, document } = parseHTML("<!doctype html><html><body></body></html>");
const storage = new Map();
Object.assign(globalThis, {
window, document, HTMLElement: window.HTMLElement, HTMLImageElement: window.HTMLImageElement,
localStorage: { getItem: (key) => storage.get(key) ?? null, setItem: (key, value) => storage.set(key, value), removeItem: (key) => storage.delete(key) },
ResizeObserver: class { observe() {} disconnect() {} },
requestAnimationFrame: (fn) => setTimeout(() => fn(performance.now()), 2), cancelAnimationFrame: clearTimeout,
});
const tr = { lang: "en", renpyName: null, str: (s) => s, line: (_id, s) => s };
const root = document.createElement("div");
document.body.append(root);
const engine = new Engine(root, structuredClone(runtime.game), { files: {} }, structuredClone(runtime.modules),
{ list: async () => [], get: async () => null, put: async () => {}, remove: async () => {} },
"runtime-test", () => {}, tr, async () => tr);
return { engine, root, window, document };
}
export const until = async (condition) => {
const deadline = performance.now() + 3000;
while (!condition()) {
if (performance.now() > deadline) throw new Error("Ожидаемое состояние плеера не наступило");
await new Promise((resolve) => setTimeout(resolve, 2));
}
};