fix: imports for browser

typescript_changes
flop 2 weeks ago
parent 96852c9105
commit a6fbd31320
  1. 30
      ts-editor/src/browser.ts

@ -2,7 +2,28 @@
// Built by: bun build src/browser.ts --target browser --outfile public/mono-display.js
import m from "mithril";
import { MonoDisplayFile, cycleTheme } from "libmonoformat";
import {
ElementType,
ElementTypeToString,
MonoDisplayDriver,
MonoDisplayFile,
MonoDisplayParser,
MonoDisplayRenderer,
SectionType,
SectionTypeToString,
StringToElementType,
StringToSectionType,
cycleTheme,
type ElementTypeName,
type MonoFormatAnimation,
type MonoFormatElement,
type MonoFormatElementsAlways,
type MonoFormatElementsTimespan,
type MonoFormatImage2D,
type MonoFormatPixelImage,
type MonoFormatSection,
type SectionTypeName
} from "libmonoformat";
const W = 120, H = 60;
@ -402,8 +423,7 @@ function triggerPreview() {
}
function buildPreview() {
if (!window.MonoDisplay) return;
if (!window._mdDriver)
if (!(window as any)._mdDriver)
window._mdDriver = new MonoDisplayDriver("canvas_root", { onColor: "#EC0", offColor: "#000", fps: 25 });
window._mdDriver.load(() => Promise.resolve(file.toBuffer()));
}
@ -418,7 +438,7 @@ function loadBin(input: HTMLInputElement) {
const reader = new FileReader();
reader.onload = e => {
try {
const parsed = new window.MonoDisplayParser().parse(e.target!.result as ArrayBuffer);
const parsed = new MonoDisplayParser().parse(e.target!.result as ArrayBuffer);
file = new MonoDisplayFile(parsed.sections);
activeSecIndex = null;
activeElIndex = null;
@ -434,7 +454,7 @@ function loadBin(input: HTMLInputElement) {
}
function exportBin() {
if (!window.MonoDisplay) { alert("MonoDisplay library not loaded."); return; }
// if (!window.MonoDisplay) { alert("MonoDisplay library not loaded."); return; }
const blob = new Blob([file.toBuffer() as any], { type: "application/octet-stream" });
const a = document.createElement("a");
a.href = URL.createObjectURL(blob);

Loading…
Cancel
Save