Skip to content
dufu1991Public

About

A pure Swift diagram rendering library for macOS. Parse Mermaid, lay out diagrams, render natively, and export PNG, SVG, and PDF. Includes the Norna Studio companion app.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

NornaKit app icon

NornaKit

English · 简体中文

CI Windows

Native diagrams, clearly.

https://nornakit.com

NornaKit is a native Mermaid diagram rendering library for macOS and Windows. The macOS implementation uses Swift and CoreGraphics; Windows uses C#, .NET 10, DirectWrite and Win2D. Parsing, text measurement, layout, rendering, and export run locally, without a browser, JavaScript runtime, or network service.

  • NornaKit provides parsing, layout, native drawing, and export. It is the primary focus of this project.
  • Norna Studio is the optional native workbench: SwiftUI on macOS, WinUI 3 on Windows. Integrating either library does not require installing the app.
A diagram rendered natively by NornaKit

Use NornaKit on macOS

Requires macOS 14 or later and Swift 6, with no external package dependencies.

Add this repository as a Swift Package dependency and link the NornaKit product. Library versions (vX.Y.Z tags) are maintained independently of Norna Studio, so depend on the library version:

.package(url: "https://github.com/dufu1991/nornakit.git", from: "0.2.0")
import NornaKit

let diagram = try await NativeDiagramRenderer().render(
    "flowchart LR\n A[Source] --> B[Native diagram]",
    options: DiagramLayoutOptions(maxWidth: 640)
)
let svg = diagram.themedSVG(.appleLight)

diagram.scene contains the native geometry. CoreGraphicsDiagramPainter draws into an AppKit graphics context, and DiagramExporter handles image and PDF output. The library product contains only the rendering engine; example catalogs live in the internal NornaExamples module used by Studio and tests. More examples and extensions are documented in the Chinese usage guide.

Use NornaKit on Windows

Requires Windows 11 build 22000 or later on x64 or ARM64. Building needs the .NET 10 SDK and Windows SDK 26100. The Windows/ solution contains the independent NornaKit.Core (pure .NET parsing, layout, scene and SVG) and NornaKit.Windows (DirectWrite, Win2D, themes, preview control and export) libraries, plus the WinUI 3 workbench.

using NornaKit;
using NornaKit.Windows;

var renderer = WindowsDiagramRenderer.Create();
var diagram = await renderer.RenderAsync(
    "flowchart LR\n A[Source] --> B[Native diagram]",
    new DiagramLayoutOptions(MaxWidth: 640), cancellationToken);
var svg = SvgExporter.Export(diagram.Scene, WindowsPalette.Resolve());

NuGet packages are not published yet; reference Windows/src/NornaKit.Core and Windows/src/NornaKit.Windows as project references for now. Parsing, layout and export run without a visible window; DiagramPreview is the optional WinUI control. See the Windows guide, in Chinese for integration, export, platform differences and packaging.

Features

  • 33 diagram families, including flowcharts, sequence, class, state, ER, Gantt, mind maps, and data charts.
  • Mermaid parsing, native text measurement, adaptive layouts, and source error locations.
  • Native scene geometry for drawing in host apps, with English and Simplified Chinese example sources.
  • System light, dark, and increased contrast appearances, with configurable diagram colors.
  • Native rich text extensions with inline icons: SF Symbols on macOS, Windows icon tokens on Windows.
  • PNG, JPEG, TIFF, SVG, and PDF export.

Syntax support varies by diagram family. See the support matrix, in Chinese for supported constructs and current limits. NornaKit does not claim complete Mermaid compatibility.

Rendering examples

A selection of common diagrams rendered by NornaKit. Previews follow your light or dark appearance; open an image to view it at full size.

Flowchart
Flowchart
Mermaid source
Sequence diagram
Sequence diagram
Mermaid source
Class diagram
Class diagram
Mermaid source
Architecture diagram
Architecture diagram
Mermaid source
Gantt chart
Gantt chart
Mermaid source
Mind map
Mind map
Mermaid source

Browse all examples

Development and validation

git clone https://github.com/dufu1991/nornakit.git
cd nornakit
swift build --target NornaKit
swift test

Library sources live in Sources/NornaKit/, with tests in Tests/NornaKitTests/ and regression fixtures in Baselines/. See the development guide, in Chinese for conventions and commands.

On Windows, run from the Windows/ directory (use -p:Platform=ARM64 on ARM64):

dotnet restore NornaKit.slnx -p:Platform=x64 --locked-mode
dotnet run --project tests/NornaKit.Core.Tests -c Release --no-restore

The example catalog in Sources/NornaExamples/Resources/examples.json and the layout fixtures in Tests/NornaKitTests/Resources/ are shared by the Swift and C# test suites.

Companion tool: Norna Studio

Norna Studio uses the same NornaKit APIs to demonstrate library capabilities, reproduce and debug rendering issues, and render Mermaid source into images, SVG, or PDF for occasional use. It provides source editing, live previews, canvas pan and zoom, and English and Simplified Chinese interfaces.

Download for macOS

Requires macOS 14 or later on an Apple Silicon Mac.

Download DMG · All releases

Open the DMG and drag Norna Studio into Applications. Releases provide one app download; the ZIP, manifest, and checksums remain in the packaging workflow artifacts.

Release notes identify the signing status. Until Apple credentials are configured, packages are ad-hoc signed and not notarized; macOS Gatekeeper may block them. Developer ID signing and notarization can be enabled in repository settings. See the release guide.

Install with Homebrew

The companion app is also distributed through the personal dufu1991/tap Cask repository. Installing by full name adds the tap automatically:

brew install --cask dufu1991/tap/norna-studio

To update:

brew update
brew upgrade --cask dufu1991/tap/norna-studio

The Cask installs the same Apple Silicon DMG published on GitHub Releases, with the same signing status, and is synchronized automatically after each release. NornaKit itself is integrated through Swift Package Manager.

Windows workbench

The WinUI 3 workbench can be built from source with dotnet publish src/NornaStudio -c Release --no-restore -p:Platform=x64 -o artifacts/studio in Windows/. Windows installers are published separately as studio-windows-vX.Y.Z releases; none has been published yet. See the Windows guide, in Chinese.

Run from source

The complete app requires Xcode 27.1 or later. Open the project and run the NornaStudio scheme:

open NornaKit.xcodeproj

You can also launch the companion tool through Swift Package Manager:

swift run NornaStudio

The Xcode app uses the native layered icon. The package executable uses its bundled static icon. See the usage guide, in Chinese for workbench and debugging instructions.

Package the companion tool

python3 -m unittest discover -s Tests/ReleaseTests -p 'test_*.py'
bash Scripts/Release/package.sh

Apple Silicon DMG and ZIP packages are written to build/release/. Packaging does not launch the app or publish a release.

CI and releases

Event Result
Push to main or PR targeting main Tests, Apple Silicon Release build, and website resource checks
Change Configuration/Studio-Version.xcconfig on main After checks pass, package and publish studio-vX.Y.Z
Manual workflow on main, with release enabled Publish the current Studio version, or recover a failed draft
Studio Release succeeds, with HOMEBREW_TAP_TOKEN configured Immediately update the Cask in dufu1991/homebrew-tap
Hourly or manual run in the tap repository Verify the latest Studio Release and synchronize its Cask, without a personal token
Push a library tag such as vX.Y.Z Does not publish the Studio app
Push or PR touching Windows/ or shared example/fixture data Windows x64 and ARM64 builds, tests, export checks and workbench launch
Manual Windows release workflow Publish the Windows installer and ZIP as studio-windows-vX.Y.Z, not marked as latest
Manual Windows NuGet workflow Publish NornaKit.Core and NornaKit.Windows to NuGet

NornaKit is the primary library product; Studio is versioned independently. Kit releases use vX.Y.Z, lead with library changes, and normally include a refreshed Studio companion build. Studio keeps its own app version and build number; separate studio-vX.Y.Z releases are reserved for app-specific updates. For a standalone app release, change MARKETING_VERSION and increment CURRENT_PROJECT_VERSION in the Studio version file. This also applies to the initial push containing that file. Ordinary commits do not create a new Release; published Studio versions are immutable. See release setup and recovery.

Repository layout

Sources/NornaKit/       Models, parsing, layouts, rendering, and export
Sources/NornaExamples/  Bilingual example catalog shared with Windows
Sources/NornaStudio/    Native app, editor, canvas, export UI, and localization
Windows/                C# libraries, WinUI 3 workbench, tests, and packaging
Tests/                 Swift tests, shared fixtures, and release automation tests
Baselines/             Versioned reference sources, SVGs, and regression snapshots
Configuration/         App metadata, entitlements, and Studio version
Scripts/               Development tools and release packaging
Branding/              Brand source assets and usage rules
Docs/                  Usage, support, development, and release documentation
website/               Static website, published assets, and generation tools
.github/workflows/     macOS and Windows CI, releases, and Homebrew sync

Package.swift defines the package. project.yml defines the XcodeGen project; NornaKit.xcodeproj is committed for direct use. After changing the project definition or adding, removing, or moving source files, run xcodegen generate. Editing the Studio version file does not require regeneration.

Build output and local design archives are excluded from Git. App and website sources share this repository. See the development guide, in Chinese, website guide, in Chinese, and brand guide, in Chinese.

Sponsor NornaKit

If NornaKit helps you build native diagrams, consider supporting its development, documentation, and ongoing maintenance. Thank you for helping the project grow.

Buy Me a Coffee · PayPal

You can also scan a QR code with WeChat or Alipay:

WeChat Alipay
WeChat sponsorship QR code Alipay sponsorship QR code

Attribution

NornaKit adapts selected measurement formulas, rendering conventions, and reference examples from Pele. See third-party notices and the licenses in the library resources. NornaKit's original code is distributed under the MIT License.

About

A pure Swift diagram rendering library for macOS. Parse Mermaid, lay out diagrams, render natively, and export PNG, SVG, and PDF. Includes the Norna Studio companion app.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages