/** * Tauri adapter for {@link LayoutGateway} (L4). Together with the sibling * adapters this is the *only* place that calls `invoke()`; components reach it * exclusively through the port. * * Commands and payload keys are camelCase, matching the backend DTO convention. * The `load_layout`/`mutate_layout` commands return the layout tree directly * (the backend `LayoutDto` is `#[serde(transparent)]` over the tree). */ import { invoke } from "@tauri-apps/api/core"; import type { LayoutKind, LayoutList, LayoutOperation, LayoutTree, PluginLayoutOrigin, } from "@/domain"; import type { LayoutGateway } from "@/ports"; export class TauriLayoutGateway implements LayoutGateway { loadLayout(projectId: string, layoutId?: string): Promise { return invoke("load_layout", { projectId, layoutId }); } mutateLayout( projectId: string, operation: LayoutOperation, layoutId?: string, ): Promise { return invoke("mutate_layout", { projectId, layoutId, operation }); } listLayouts(projectId: string): Promise { return invoke("list_layouts", { projectId }); } createLayout( projectId: string, name: string, kind?: LayoutKind, pluginOrigin?: PluginLayoutOrigin, ): Promise<{ layoutId: string }> { return invoke<{ layoutId: string }>("create_layout", { request: { projectId, name, kind, pluginOrigin }, }); } renameLayout(projectId: string, layoutId: string, name: string): Promise { return invoke("rename_layout", { request: { projectId, layoutId, name }, }); } deleteLayout(projectId: string, layoutId: string): Promise<{ activeId: string }> { return invoke<{ activeId: string }>("delete_layout", { request: { projectId, layoutId }, }); } setActiveLayout(projectId: string, layoutId: string): Promise<{ activeId: string }> { return invoke<{ activeId: string }>("set_active_layout", { request: { projectId, layoutId }, }); } }