דלגו לתוכן

Extension SDK

הרחבות drawtonomy הן אפליקציות web מארחות-iframe שמדברות עם העורך דרך postMessage. ה-SDK נותן לכם לקוח מוקלד; ה-dev-server נותן לכם עורך מקומי לפתח מולו.

עמוד זה הוא התמצאות מהירה. המדריך המלא — סכמת manifest, רשימת capabilities, פרוטוקול הודעות — נמצא במאגר הציבורי:

מדריך פיתוח הרחבות (日本語)

Terminal window
# Editor on :3000
pnpm add -g @drawtonomy/dev-server
drawtonomy-dev-server
# Your extension on :3001
cd my-extension && pnpm dev --port 3001
open "http://localhost:3000/?ext=http://localhost:3001/manifest.json"
my-extension/
manifest.json
index.html
src/
manifest.json
{
"id": "my-extension",
"name": "My Extension",
"version": "1.0.0",
"entry": "./index.html",
"capabilities": ["shapes:read", "shapes:write", "ui:panel"]
}
src/main.ts
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' })])
})

ההרחבות in-tree הן דוגמאות בנאמנות מלאה: