2024-09-29 18:27:50 +00:00
|
|
|
import "../lib/wasm_exec.js";
|
|
|
|
|
|
|
|
// @ts-expect-error: no types
|
|
|
|
const go = new Go();
|
|
|
|
|
|
|
|
const code =
|
|
|
|
await (await fetch(import.meta.url.replace("/mod.ts", "/mod.wasm")))
|
|
|
|
.arrayBuffer();
|
|
|
|
|
|
|
|
const wasmMmodule = await WebAssembly.instantiate(code, go.importObject);
|
|
|
|
const wasm = wasmMmodule.instance;
|
|
|
|
|
|
|
|
go.run(wasm);
|
|
|
|
|
|
|
|
// @ts-ignore: no types
|
2024-10-03 21:42:50 +00:00
|
|
|
const _exports = __InitPlotExports() as Record<string, (...args: unknown[]) => unknown>;
|
2024-09-29 18:27:50 +00:00
|
|
|
|
|
|
|
for (const key in _exports) {
|
|
|
|
const draw = _exports[key];
|
|
|
|
const drawKey = "Draw" + key;
|
|
|
|
_exports[drawKey] = (...args: unknown[]) => {
|
|
|
|
const data = "data:image/png;base64," + draw(...args);
|
|
|
|
return {
|
|
|
|
[Symbol.for("Jupyter.display")]: () => ({
|
|
|
|
"text/markdown": `![name](${data})`,
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default _exports;
|