feat: add native Tomie adapter and strict import compatibility checks

This commit is contained in:
mrleo1nid committed 2026-10-25 11:02:52 +03:00
1 parent c8d83b3fe7
commit 57a4edcbfd
45 files changed
+2985 -71

No files matched your search

+29
View File
@@ -38,3 +38,32 @@ test("Naninovel AST runs through the shared store and survives JSON saves", asyn
py.exec([{ op: "set", t: { k: "name", id: "score" }, v: { k: "nani", ast: bin("+", n("score"), c(4)) } }]);
assert.equal(JSON.parse(JSON.stringify(store)).score, 6);
});
test("the player presents translated Naninovel choices and jumps after selection", async () => {
const { Engine } = await load("engine");
class Element {
children = [];
style = {};
classList = { add() {}, remove() {} };
append(child) { this.children.push(child); }
set textContent(value) { this.children = value ? [value] : []; }
}
const previousDocument = globalThis.document;
globalThis.document = { createElement: () => new Element() };
try {
const engine = Object.create(Engine.prototype);
Object.assign(engine, { store: {}, game: { engine: "naninovel", naniExpressions: {} },
tr: { line: (_tid, text) => text === "Again" ? "Ещё раз" : text },
menuEl: new Element(), baseSize: 28, interactionStart() {}, setSkip() {},
advance() {}, jump(target) { this.chosenTarget = target; },
wait(setup) { return new Promise((resolve) => { setup(resolve); this.menuEl.children[0].onclick({ stopPropagation() {} }); }); } });
await engine.exec({ op: "nani_add_choice", what: "Again", tid: "choice-id", target: "nani:Opening", handler: "" });
assert.equal(JSON.parse(JSON.stringify(engine.store)).__nani_choices[0].tid, "choice-id");
await engine.exec({ op: "nani_menu" });
assert.equal(engine.menuEl.children[0].children[0], "Ещё раз");
assert.equal(engine.chosenTarget, "nani:Opening");
assert.deepEqual(engine.store.__nani_choices, []);
} finally {
globalThis.document = previousDocument;
}
});