npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@miragon/team-topologies-renderer

v0.5.0

Published

Render and edit Team Topologies diagrams in the browser, with a framework-agnostic viewer and modeler built on diagram-js.

Downloads

474

Readme

@miragon/team-topologies-renderer

npm License: MIT

The browser layer of the Team Topologies Modeler: a framework-agnostic viewer and full editor for Team Topologies diagrams, built on diagram-js (MIT).

It renders the canonical document from @miragon/team-topologies-schema-model and gives you palette, move, resize, connect-by-overlap, context pad, inline label editing and undo/redo — with no UI framework required. Mount it into any <div>; the web app (React) and the VS Code extension both wrap this exact package.

Install

npm install @miragon/team-topologies-renderer @miragon/team-topologies-schema-model

Three entry points

| Class | Use it for | | ----------------- | ------------------------------------------------------------------------------ | | Viewer | Read-only rendering, no interaction (thumbnails, static embeds). | | NavigatedViewer | Read-only + zoom (scroll), pan (drag) and selection. | | Modeler | The full editor: palette, move, resize, context pad, label editing, undo/redo. |

All three share a common base (TtBaseViewer) with the same import/export and lifecycle API.

Quick start

import { Modeler } from "@miragon/team-topologies-renderer";
import "@miragon/team-topologies-renderer/assets/team-topologies.css";
import { SAMPLE_DOCUMENT } from "@miragon/team-topologies-schema-model";

const modeler = new Modeler({ container: document.querySelector("#canvas")! });

// Load a document (auto-fits the viewport)
const { warnings } = modeler.importDocument(SAMPLE_DOCUMENT);

// Read the live canvas back as the canonical model
const doc = modeler.exportDocument();

// Export a standalone, self-contained SVG
const { svg } = modeler.saveSVG();

// Undo / redo are driven by the command stack
modeler.undo();
modeler.redo();

The CSS is required. Import @miragon/team-topologies-renderer/assets/team-topologies.css (it also pulls in diagram-js's own stylesheet) — without it the palette, context pad and label editor are unstyled.

API

Constructor — TtViewerOptions

new Modeler({
  container?: HTMLElement,            // host element (a detached <div> if omitted)
  width?: number | string,           // canvas width  (default "100%")
  height?: number | string,          // canvas height (default "100%", or "600px" with no container)
  additionalModules?: ModuleDeclaration[], // extra diagram-js modules
});

Shared methods (Viewer / NavigatedViewer / Modeler)

| Method | Returns | Purpose | | ---------------------------------- | ------------------------------- | ------------------------------------------------- | | importDocument(doc) | { warnings: ImportWarning[] } | Replace canvas content and auto-fit. | | exportDocument() | TtDocument | Rebuild the canonical model from the live canvas. | | saveSVG() | { svg: string } | Self-contained SVG snapshot (fitted viewBox). | | setMeta(partial) / getMeta() | — / RootBusinessObject | Read/write diagram-level metadata (e.g. title). | | attachTo(el) / detach() | void | Move the canvas in/out of the DOM (keeps state). | | clear() / destroy() | void | Empty the canvas / tear it down. | | on(event, cb) / off(event, cb) | void | Subscribe to diagram-js events. | | get<T>(name) | T | Resolve a diagram-js service (advanced). |

Modeler-only

undo(), redo(), canUndo(), canRedo().

Helpers & types

  • Type guards: isTtElement, isTtTeam, isTtInteraction, isTtFlow.
  • Runtime element types: TtTeam, TtInteraction, TtFlow, TtElement.
  • Palette icon generators: teamIconSvg(type), interactionIconSvg(mode), flowIconSvg() — WYSIWYG SVG glyphs matching what the canvas draws.
  • Other: TtViewerOptions, ImportWarning, RootBusinessObject, ROOT_ID, saveSVG.

How it's built

The package is a set of didi modules layered on diagram-js. Each is exported (e.g. ttDrawModule, ttPaletteModule, ttModelingModule) so you can compose your own viewer via additionalModules:

| Module | Responsibility | | ---------------------- | -------------------------------------------------------------------------------- | | ttModelModule | Element factory with notation defaults (TtElementFactory). | | ttDrawModule | Custom SVG rendering of teams, interactions and flow (TeamTopologiesRenderer). | | ioModule | Document ↔ canvas bridge (TtImporter, TtExporter, saveSVG). | | ttModelingModule | High-level mutations — label, team type, interaction mode, colours, description. | | ttRulesModule | Editing rules (what can move / resize / be created). | | ttBehaviorsModule | Keeps the model flat — shapes never nest. | | ttPaletteModule | The drag-to-create tool palette. | | ttContextPadModule | Per-element actions (rename, delete). | | ttLabelEditingModule | Double-click inline label editing. | | ttKeyboardModule | Undo / redo / delete shortcuts. | | ttZOrderModule | Fixed stacking order (flow behind, teams, interactions on top). |

Rendering

A custom TeamTopologiesRenderer (priority 1500, beating diagram-js's default) draws each element from the spec in @miragon/team-topologies-schema-model: the four team outlines (octagon, vertical/horizontal rounded rectangles, square rectangle) drawn solid; the three interaction glyphs (parallelogram, triangle, circle) drawn dashed and translucent; the flow-of-change as a dashed left-to-right band. Labels are word-wrapped and centred. Per-element fill/stroke overrides win over the spec defaults.

Import / export

The package reads and writes the canonical TtDocument (JSON) and exports a standalone SVG. PNG export and the embedded-scene round-trip (storing the document inside the exported image) live in the web app and the VS Code extension, which add the canvas rasterisation those formats need.

Development

Part of the Team Topologies Modeler monorepo; consumed from source by the apps. From the repo root:

npm run build -w packages/renderer   # Vite library build → dist/ (publish build)
npm test                             # Vitest unit tests
npm run test:browser                 # renderer integration tests in real Chromium
npm run typecheck

License

MIT. diagram-js and its dependencies are MIT / ISC / Apache-2.0.