import { Dataminer } from "./mod.ts";Dataminer.withLogs(true);Dataminer.setOodle("...");const core = new Dataminer("...");console.log(core); // printedcore.setVersionUE5(1008); // crashes here?console.log("set version"); // not printed
const DLL_PATH = "...";const library = Deno.dlopen(DLL_PATH, { "dataminer_options_with_oodle": { parameters: ["buffer"], result: "void" }, "dataminer_with_logging": { parameters: ["bool"], result: "void" }, "dataminer_construct": { parameters: ["buffer"], result: "pointer" }, "dataminer_set_version_ue5": { parameters: ["pointer", "i32"], result: "void" }});function encode(text: string) { return new TextEncoder().encode(text);}export class Dataminer { pointer: Deno.PointerValue; constructor(paksDir: string) { this.pointer = library.symbols.dataminer_construct(encode(paksDir)); } checkPointer() { if (!this.pointer) throw new Error("pointer is null"); } static setOodle(oodlePath: string) { library.symbols.dataminer_options_with_oodle(encode(oodlePath)); } static withLogs(shouldLog: boolean) { library.symbols.dataminer_with_logging(shouldLog); } setVersionUE5(version: number) { this.checkPointer(); library.symbols.dataminer_set_version_ue5(this.pointer, version); }}