Skip to content
asciimothPublic

Latest commit

 

History

39 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

formular

Formular is a JSON message DSL for backend-owned dynamic menus and forms that can be rendered by GUI, TUI, CLI, MCP, web, or other frontends. It also supports backend-requested one-shot yes/no, selection, and captcha dialogs through asynchronous messages.

Almagest is a real-world project that uses Formular.

JavaScript frontend

The npm package entry point is a single dependency-free browser file:

import { FormularMenu } from "@asciimoth/formular-menu";

const menu = new FormularMenu("root", "settings", (message) => {
  console.log("frontend message", message);
}, {
  renderMultilineTextInput(textarea, { field }) {
    if (field.subtype !== "json") return undefined;
    const editor = document.createElement("span");
    editor.className = "json-editor";
    editor.append(textarea);
    return editor;
  }
});

The optional renderMultilineTextInput hook can wrap multiline textareas for syntax highlighting and other custom presentation. The native textarea stays in control of values, validation, readonly state, and messages. See the JavaScript frontend documentation for the full contract.

Run the local WASM demo:

pnpm install
pnpm run demo

The demo renders two independent frontends and a Go WASM backend connected by one merged JSON message channel. Its JSON configuration field uses the custom multiline rendering hook for live syntax highlighting.

License

Files in this repository are distributed under the CC0 license.

CC0
To the extent possible under law, ASCIIMoth has waived all copyright and related or neighboring rights to formular.

Releases

Contributors

Languages