openpencil/packages/cli/src/headless.ts
Danila Poyarkov c3f5189f8f style: tighten import grouping
- Configure oxfmt custom import groups for workspace, app, package, and test aliases
- Keep type imports grouped with their matching source category instead of one global tail group
- Expand the format script to cover formatter config, Vite files, and scripts
2026-05-06 02:22:08 +03:00

15 lines
550 B
TypeScript

import { BUILTIN_IO_FORMATS, IORegistry, initCanvasKit } from '@open-pencil/core/io'
import { computeAllLayouts } from '@open-pencil/core/layout'
import type { SceneGraph } from '@open-pencil/core/scene-graph'
export { initCanvasKit }
const io = new IORegistry(BUILTIN_IO_FORMATS)
export async function loadDocument(filePath: string): Promise<SceneGraph> {
const bytes = new Uint8Array(await Bun.file(filePath).arrayBuffer())
const { graph } = await io.readDocument({ name: filePath, data: bytes })
computeAllLayouts(graph)
return graph
}