Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Plugin System Overview

typewriter v0.5.2 introduced a dynamic plugin architecture. In v1.0.0 this remains experimental: local plugin loading is available, but there is no plugin add command, registry marketplace, or stable community plugin ABI.

How It Works

  1. Plugin authors implement the EmitterPlugin trait from the typewriter-plugin crate
  2. Plugins are compiled as shared libraries (.so / .dylib / .dll)
  3. The CLI dynamically loads plugins at startup via libloading
  4. Plugins provide TypeMapper implementations just like built-in emitters

Architecture

┌─────────────────┐       ┌──────────────────┐
│  typebridge CLI │──────▶│  PluginRegistry   │
└─────────────────┘       └────────┬─────────┘
                                   │
                    ┌──────────────┼──────────────┐
                    ▼              ▼              ▼
            ┌──────────┐  ┌──────────┐  ┌──────────┐
            │   Ruby   │  │   PHP    │  │   Dart   │
            │  .so/.dll│  │  .so/.dll│  │  .so/.dll│
            └──────────┘  └──────────┘  └──────────┘

Key Components

ComponentCratePurpose
EmitterPlugin traittypewriter-pluginInterface for plugin implementations
declare_plugin! macrotypewriter-pluginGenerates C ABI entry points
PluginRegistrytypewriter-engineLoads and manages plugins
PluginConfigtypewriter-pluginPlugin-specific config from TOML

Bundled Plugins

PluginLanguage IDExtensionDescription
typewriter-plugin-rubyruby.rbiSorbet type signatures
typewriter-plugin-phpphp.phpPHP 8.1+ readonly classes
typewriter-plugin-dartdart.dartjson_serializable classes

Limitations

  • CLI only — plugins are loaded at CLI startup, not during cargo build proc-macro expansion
  • No hot reload — plugins are loaded once; restart CLI after changes
  • ABI versioning — plugins must match PLUGIN_API_VERSION, and the ABI is not stable in v1.0.0