|
|
|
@ -2,7 +2,28 @@ |
|
|
|
// Built by: bun build src/browser.ts --target browser --outfile public/mono-display.js
|
|
|
|
// Built by: bun build src/browser.ts --target browser --outfile public/mono-display.js
|
|
|
|
|
|
|
|
|
|
|
|
import m from "mithril"; |
|
|
|
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; |
|
|
|
const W = 120, H = 60; |
|
|
|
@ -402,8 +423,7 @@ function triggerPreview() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function buildPreview() { |
|
|
|
function buildPreview() { |
|
|
|
if (!window.MonoDisplay) return; |
|
|
|
if (!(window as any)._mdDriver) |
|
|
|
if (!window._mdDriver) |
|
|
|
|
|
|
|
window._mdDriver = new MonoDisplayDriver("canvas_root", { onColor: "#EC0", offColor: "#000", fps: 25 }); |
|
|
|
window._mdDriver = new MonoDisplayDriver("canvas_root", { onColor: "#EC0", offColor: "#000", fps: 25 }); |
|
|
|
window._mdDriver.load(() => Promise.resolve(file.toBuffer())); |
|
|
|
window._mdDriver.load(() => Promise.resolve(file.toBuffer())); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -418,7 +438,7 @@ function loadBin(input: HTMLInputElement) { |
|
|
|
const reader = new FileReader(); |
|
|
|
const reader = new FileReader(); |
|
|
|
reader.onload = e => { |
|
|
|
reader.onload = e => { |
|
|
|
try { |
|
|
|
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); |
|
|
|
file = new MonoDisplayFile(parsed.sections); |
|
|
|
activeSecIndex = null; |
|
|
|
activeSecIndex = null; |
|
|
|
activeElIndex = null; |
|
|
|
activeElIndex = null; |
|
|
|
@ -434,7 +454,7 @@ function loadBin(input: HTMLInputElement) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function exportBin() { |
|
|
|
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 blob = new Blob([file.toBuffer() as any], { type: "application/octet-stream" }); |
|
|
|
const a = document.createElement("a"); |
|
|
|
const a = document.createElement("a"); |
|
|
|
a.href = URL.createObjectURL(blob); |
|
|
|
a.href = URL.createObjectURL(blob); |
|
|
|
|