扩展 SDK
drawtonomy 扩展是托管在 iframe 中的 Web 应用,
通过 postMessage 与编辑器通信。SDK 提供了类型化的客户端;
dev-server 则提供本地编辑器供你开发。
本页是一份快速指南。完整说明——manifest schema、 能力(capabilities)列表、消息协议——位于公开仓库:
➡ Extension Development Guide (日本語)
# 编辑器在 :3000pnpm add -g @drawtonomy/dev-serverdrawtonomy-dev-server
# 你的扩展在 :3001cd my-extension && pnpm dev --port 3001
open "http://localhost:3000/?ext=http://localhost:3001/manifest.json"一个最小扩展
Section titled “一个最小扩展”my-extension/ manifest.json index.html src/{ "id": "my-extension", "name": "My Extension", "version": "1.0.0", "entry": "./index.html", "capabilities": ["shapes:read", "shapes:write", "ui:panel"]}import { ExtensionClient, createVehicle } from '@drawtonomy/sdk'
const client = new ExtensionClient()await client.ready()
document.getElementById('add')!.addEventListener('click', async () => { await client.addShapes([createVehicle(0, 0, { templateId: 'sedan' })])})仓库内置的扩展是完整保真示例:
ai-scene-generator— 自然语言与 OpenSCENARIO 场景生成。template-preview— 预览图形模板。exporter-playground— 在画布上即时调试导出器。path-footprint-lab— Path Footprint 实验。
- 扩展架构 — 为什么使用 iframe 与 postMessage。
@drawtonomy/sdk概览 — 包及其模块。