SDK degli esportatori
L’esportatore è un insieme di funzioni pure su
DrawtonomySnapshot. Aggiungere un nuovo formato target è
autonomo: un nuovo modulo, qualche test e un hook UI opzionale.
Questa pagina è un orientamento rapido. La guida completa — architettura, API, pattern di test, controlli visivi esmini — è nel repo pubblico:
➡ Exporter Developer Guide (日本語)
Avvio rapido
Sezione intitolata “Avvio rapido”git clone https://github.com/kosuke55/drawtonomy.gitcd drawtonomypnpm installcd packages/drawtonomy-sdkpnpm exec vitest exporter # modalità watchEsportatore minimo
Sezione intitolata “Esportatore minimo”import type { DrawtonomySnapshot } from '../types'
export function exportToMyFormat(snapshot: DrawtonomySnapshot): string { // Itera sulle forme, emetti il tuo formato. return ''}import { describe, it, expect } from 'vitest'import { exportToMyFormat } from '../../src/exporter/my-format'import { createSnapshot, createLane } from '../../src/index'
describe('my-format exporter', () => { it('emits expected payload for a single lane', () => { const snapshot = createSnapshot([createLane(/* ... */)]) expect(exportToMyFormat(snapshot)).toContain('<expected/>') })})Usare una scena reale come fixture
Sezione intitolata “Usare una scena reale come fixture”I file drawtonomy.svg fanno il round-trip attraverso l’SDK,
quindi puoi creare una scena nell’editor e usarla come input per
test di regressione:
import { readFileSync } from 'node:fs'import { parseDrawtonomySvg } from '@drawtonomy/sdk'
const svg = readFileSync('./fixtures/my-scene.drawtonomy.svg', 'utf-8')const snapshot = parseDrawtonomySvg(svg)!Vedi anche
Sezione intitolata “Vedi anche”- Architettura dell’esportatore — la pipeline e perché è pura.
- Panoramica
@drawtonomy/sdk