Exporter SDK
المُصدِّر مجموعة من الدوال النقية فوق DrawtonomySnapshot. إضافة صيغة هدف جديدة عمل قائم بذاته: وحدة جديدة، وبضعة اختبارات، وخطاف اختياري لواجهة المستخدم.
هذه الصفحة توجيه سريع. الدليل الكامل — البنية وواجهة API وأنماط الاختبار وفحوص esmini البصرية — في المستودع العام:
بدء سريع
Section titled “بدء سريع”git clone https://github.com/kosuke55/drawtonomy.gitcd drawtonomypnpm installcd packages/drawtonomy-sdkpnpm exec vitest exporter # وضع المراقبةمُصدِّر جديد بحدّ أدنى
Section titled “مُصدِّر جديد بحدّ أدنى”import type { DrawtonomySnapshot } from '../types'
export function exportToMyFormat(snapshot: DrawtonomySnapshot): string { // امرّ على الأشكال وأخرج صيغتك. 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/>') })})استخدم مشهدًا حقيقيًا كملف اختبار
Section titled “استخدم مشهدًا حقيقيًا كملف اختبار”تمرّ ملفات drawtonomy.svg عبر SDK في دورة كاملة، فيمكنك تأليف مشهد في المحرر واستخدامه كمدخل اختبار انحدار:
import { readFileSync } from 'node:fs'import { parseDrawtonomySvg } from '@drawtonomy/sdk'
const svg = readFileSync('./fixtures/my-scene.drawtonomy.svg', 'utf-8')const snapshot = parseDrawtonomySvg(svg)!انظر أيضًا
Section titled “انظر أيضًا”- بنية المُصدِّر — خط الأنابيب ولماذا هو نقي.
- نظرة عامة على
@drawtonomy/sdk