Getting Started
Welcome to the SCXML TypeScript Parser documentation! This library provides a comprehensive, type-safe way to work with SCXML (State Chart XML) documents in TypeScript and JavaScript applications.
What is SCXML?โ
SCXML (State Chart XML) is a W3C standard that provides a generic state-machine based execution environment. It's used to control the logic of applications, from simple UI state management to complex business workflows and AI agent behavior.
Featuresโ
- ๐ Full SCXML Support: Complete implementation of W3C SCXML specification
- ๐๏ธ Builder API: Fluent, type-safe API for creating SCXML documents
- ๐ง Modification API: Programmatically modify existing SCXML documents
- โ Validation: Comprehensive validation with detailed error reporting
- ๐ XML Serialization: Convert SCXML documents back to XML
- ๐ฏ TypeScript: Full TypeScript support with complete type definitions
- โก Performance: Efficient parsing and manipulation of large state machines
- ๐งช Well Tested: Comprehensive test suite with edge case coverage
Installationโ
Install the package using npm or yarn:
npm install @scxml/parser
Quick Exampleโ
Here's a simple example to get you started:
import { SCXML } from "@scxml/parser";
// Create a simple state machine
const document = SCXML.create()
.name("traffic-light")
.initial("red")
.addState(
SCXML.state("red")
.addTransition(SCXML.transition().event("timer").target("green").build())
.build()
)
.addState(
SCXML.state("green")
.addTransition(SCXML.transition().event("timer").target("yellow").build())
.build()
)
.addState(
SCXML.state("yellow")
.addTransition(SCXML.transition().event("timer").target("red").build())
.build()
)
.build();
// Validate the document
const errors = SCXML.validate(document);
if (errors.length === 0) {
console.log("Valid SCXML document!");
}
// Convert to XML
const xml = SCXML.serialize(document, { spaces: 2 });
console.log(xml);
What's Next?โ
- Learn the core concepts of SCXML and this library
- See practical examples to build your first state machine
- Explore the API reference for detailed documentation
- See more examples for common use cases
Need Help?โ
- ๐ Check out the examples section
- ๐ Report issues on GitHub
- ๐ฌ Ask questions on Stack Overflow with the
scxmltag