Merge branch 'main' into gh-pages

This commit is contained in:
Parker TenBroeck 2026-01-10 11:48:24 -05:00
commit aad37e5b84
3 changed files with 25 additions and 15 deletions

View file

@ -197,3 +197,12 @@ export type Tm = {
edges: Map<string, Edge[]>; edges: Map<string, Edge[]>;
}; };
export type FaState = {
state: State,
position: number
}
export class FaSim{
}

View file

@ -73,11 +73,12 @@ export function updateGraphTheme() {
network.setOptions({ network.setOptions({
nodes: { nodes: {
labelHighlightBold: false,
font: { font: {
color: gt.fg_0, color: gt.fg_0,
bold: { bold: {
color: gt.fg_1, color: gt.fg_1,
mod: "", // mod: "",
}, },
}, },
}, },
@ -85,13 +86,15 @@ export function updateGraphTheme() {
labelHighlightBold: true, labelHighlightBold: true,
font: { font: {
align: "top", align: "top",
face: 'arial',
size: gt.edge_font_size, size: gt.edge_font_size,
color: gt.fg_0, color: gt.fg_0,
strokeColor: gt.bg_0, strokeColor: gt.bg_0,
bold: { bold: {
color: gt.fg_1, color: gt.fg_1,
face: 'arial',
size: gt.edge_font_size, size: gt.edge_font_size,
mod: "", mod: "bold",
}, },
}, },
color: { color: {
@ -113,6 +116,7 @@ let automaton: Machine = {
initial_state: "", initial_state: "",
states: new Map(), states: new Map(),
transitions: new Map(), transitions: new Map(),
transitions_components: new Map(),
edges: new Map(), edges: new Map(),
}; };
@ -124,6 +128,7 @@ export function clearAutomaton() {
initial_state: "", initial_state: "",
states: new Map(), states: new Map(),
transitions: new Map(), transitions: new Map(),
transitions_components: new Map(),
edges: new Map(), edges: new Map(),
}; };
} }
@ -147,12 +152,16 @@ export function setAutomaton(auto: Machine) {
} }
} }
// // Populate edges // Populate edges
for (const [edge_id, transitions] of auto.edges) { for (const [edge_id, transitions] of auto.edges) {
const to_from = edge_id.split("#"); const to_from = edge_id.split("#");
const vadjust = -getGraphTheme().edge_font_size *
Math.floor(transitions.length / 2);
const font = { const font = {
vadjust: -getGraphTheme().edge_font_size * vadjust,
Math.floor(transitions.length / 2), bold: {
vadjust
}
}; };
if (edges.get(edge_id)) { if (edges.get(edge_id)) {
edges.update({ edges.update({
@ -272,7 +281,7 @@ function renderNode({
state: { selected, hover }, state: { selected, hover },
style, style,
label, label,
}: any) { }: {ctx: CanvasRenderingContext2D, id: string, x: number, y: number, state: {selected: boolean, hover: boolean}, style: any, label: string}) {
return { return {
drawNode() { drawNode() {
const t = getGraphTheme(); const t = getGraphTheme();
@ -294,6 +303,7 @@ function renderNode({
ctx.save(); ctx.save();
ctx.font = hover||selected?'bold 14px arial':'14px arial';
ctx.textAlign = "center"; ctx.textAlign = "center";
ctx.textBaseline = "middle"; ctx.textBaseline = "middle";
@ -352,7 +362,6 @@ function renderNode({
// } // }
// } // }
// @ts-expect-error bad library
const node: vis.Node = nodes.get(id)!; const node: vis.Node = nodes.get(id)!;
const physicsOff = node.physics === false; const physicsOff = node.physics === false;
if (physicsOff) { if (physicsOff) {

View file

@ -5,14 +5,6 @@ use automata::loader::{self, Context, Span, Spanned, lexer::Lexer};
use serde::Serialize; use serde::Serialize;
use wasm_bindgen::prelude::wasm_bindgen; use wasm_bindgen::prelude::wasm_bindgen;
#[wasm_bindgen]
pub fn test() {
panic!()
}
#[wasm_bindgen(start)]
pub fn main() {}
#[wasm_bindgen] #[wasm_bindgen]
pub fn init() { pub fn init() {
console_error_panic_hook::set_once(); console_error_panic_hook::set_once();