- 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
15 lines
550 B
TypeScript
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
|
|
}
|