Sprotty is a next-generation, open-source diagramming framework built with web technologies, primarily TypeScript. It provides a robust, extensible foundation for creating interactive graphical views in web applications and rich clients. The framework excels in fast, scalable SVG rendering with built-in animations, supporting both client-side-only and distributed (client/server) runtimes. Currently at version 1.4.0, it maintains an active release cadence with several minor versions per year since reaching maturity with its 1.0.0 release. Key differentiators include its reactive client architecture, a highly configurable dependency injection system (based on InversifyJS), and seamless integration capabilities with tools and ecosystems like Xtext, Langium, the Language Server Protocol (LSP), VS Code, and Theia, enabling the development of complex graphical editors and sophisticated visualizations. It leverages JSX for declarative view definition and standard CSS for comprehensive styling.
npm install sprottyVerified import paths — ran on the pinned version, not inferred.
This quickstart sets up a basic client-side Sprotty diagram using a local model source, demonstrating dependency injection configuration, model definition with a simple graph, two nodes, and an edge, and rendering it into a specified HTML element.
Review the `CHANGELOG.md` files for `sprotty` and `sprotty-protocol` packages to identify removed APIs and update your code to use their stable replacements. Rebuilding your project and addressing TypeScript errors is usually sufficient.
Ensure your `package.json` specifies `inversify` with a compatible version, typically `^6.1.3` or as indicated by the latest Sprotty documentation. Always `npm install` or `yarn install` after changes.
Stay informed about new major releases and changelogs. Be prepared to update build configurations (e.g., Webpack, ESBuild) and import statements when the official ESM transition occurs.
Ensure the chosen `ModelSource` implementation (configured via InversifyJS) matches your application's architecture. For client-only diagrams, use `LocalModelSource`. For distributed diagrams, set up `DiagramServerProxy` and a corresponding server.
Inspect your `ContainerModule` definitions. Ensure `loadDefaultModules` is called, and all custom model elements, views, and services have a corresponding `bind` statement. Check for typos in `TYPES` keys or class names. Refer to the 'Dependency Injection' section of Sprotty's documentation.
Verify that the `containerId` passed to `setupSprottyDiagram` (or similar initialization function) correctly matches the ID of an existing HTML `div` element in your DOM, and that the script runs after the DOM is fully loaded.
Add `import 'reflect-metadata';` at the very top of your application's entry TypeScript/JavaScript file before any other imports. Ensure `reflect-metadata` is installed (`npm install reflect-metadata`).
Ensure `sprotty` and `sprotty-protocol` are installed. If using an older TypeScript version or complex setup, check `tsconfig.json` for `moduleResolution` and `typeRoots`. Modern setups rarely need `@types/sprotty` as types are shipped with the package.