import { ref, watch, type Ref } from 'vue' import type { Template } from '../core/types' import type { LayoutResult, LayoutMapEntry } from '../core/layout-types' export type { LayoutMapEntry } /** Discriminated union for all messages the layout worker can send back */ type WorkerResponse = | { type: 'result'; layout: LayoutResult; id: number } | { type: 'error'; error: string; id: number } | { type: 'barcode-result'; width: number; height: number; rgba: ArrayBuffer; id: number } | { type: 'barcode-error'; error: string; id: number } export interface LayoutEngineOptions { /** Font API base URL. Default: '/api/fonts' */ fontApiBase?: string } export function useLayoutEngine( template: Ref