@markdy/core
v0.8.3
Published
MarkdyScript parser and diagram compiler (auto-layout, edge routing, cue scheduling) — zero runtime dependencies.
Downloads
5,378
Maintainers
Readme
@markdy/core
The parser and AST types for MarkdyScript — a DSL for describing 2D animated scenes.
Features
- Zero runtime dependencies — pure TypeScript, no DOM or platform APIs
- Single-pass parser — line-by-line state machine with strict
ParseErrordiagnostics - Rich type system —
var,def,seqexpanded at parse time for composable scene authoring - Isomorphic — runs in Node.js, Deno, Bun, edge runtimes, and the browser
Installation
pnpm add @markdy/corePackage position (text)
@markdy/core
-> parser + AST types (no DOM, no runtime deps)
-> foundation for renderer, CLI, language server, and integrationsOutput preview
Usage
import { parse, ParseError } from "@markdy/core";
import type { DiagramAST } from "@markdy/core";
const source = `
scene "Request" theme=paper
browser Web
service API
beat main:
show $nodes
Web -> API "GET /users"
`;
try {
const ast: DiagramAST = parse(source);
console.log(ast.meta); // { width: 1280, height: 720, fps: 60, theme: "midnight", direction: "LR", title: "Request" }
console.log(ast.nodes); // { Web: { kind: "browser", ... }, API: { kind: "service", ... } }
console.log(ast.beats); // [{ name: "main", cues: [...] }]
} catch (e) {
if (e instanceof ParseError) {
console.error(`Line ${e.line}: ${e.message}`);
}
}Exports
| Export | Type | Description |
|---|---|---|
| parse | (source, opts?) => DiagramAST | Parse MarkdyScript source into a diagram AST |
| compile | (ast) => RenderPlan | Lay out nodes, route edges, and schedule cues |
| parseAndCompile | (source) => { ast, plan } | Parse and compile in one call |
| ParseError | class | Error with .line number for diagnostics |
| DiagramAST | type | Parsed scene: meta, nodes, edges, groups, patterns, beats |
| RenderPlan | type | Positioned nodes, routed edges, timed cues, beat ranges |
| SceneMeta | type | Scene configuration (width, height, fps, theme, direction) |
| NodeDecl | type | Node declaration (kind, id, label, style) |
| EdgeDecl | type | Edge declaration (kind, from, to, label) |
| BeatDecl | type | Named beat with cues |
| THEMES / resolveTheme | tokens | Semantic theme palettes (midnight, paper) |
Documentation
- Syntax Reference — complete DSL language spec
- Tutorial — step-by-step guide
- Agent Guide — structured reference for AI/LLM code generation
- Architecture — parser internals and design decisions
