import type { EngineAdapter } from "./EngineAdapter"; import type { BlockHit, CaretRect, CellAddr, CellCaretRect, CellHit, CellTextHit, DocProfile, FindMatch, FindOptions, FindReplaceOptions, HitResult, ImageBox, Intent, OpenResult, Outcome, OutlineItem, PageGeom, ProposalV1, ReplaceResult, RunSpec, TableBox, TableGrid } from "./types"; /** The `invoke` surface (matches `@tauri-apps/api/core`'s `invoke`). Injected so this package has NO * hard @tauri-apps dependency — the host passes its own `invoke`. */ export type Invoke = (cmd: string, args?: Record) => Promise; export type DesktopSessionStatus = { documentId: string | null; revision: number; savedRevision: number; dirty: boolean; hasSource: boolean; }; export interface TauriAdapterOptions { /** The Tauri `invoke`. */ invoke: Invoke; /** The desktop app opens documents by PATH (a native file dialog), not by bytes. The host supplies * this to bridge the web `open(bytes)` seam — e.g. write the bytes to a temp file and return the * path. Reference impl: the real app migration (issue 044) wires this to a Tauri command. */ resolveOpenPath?: (bytes: Uint8Array, name?: string) => Promise; /** Optional host-owned open dispatcher. Desktop recovery uses this to open app-data HWPX bytes by * opaque recovery id without manufacturing a source path or exposing it to the shared workspace. */ openDocument?: (bytes: Uint8Array, name?: string) => Promise; } export declare class TauriAdapter implements EngineAdapter { private invoke; private resolveOpenPath?; private openDocument?; private lastRevision; /** Fires only when the authoritative Rust revision changed, never for read-only Intent queries. */ onMutation: (() => void) | null; /** Host chrome observes open/save/dirty transitions without putting paths in React state. */ onSessionStatus: ((status: DesktopSessionStatus) => void) | null; constructor(opts: TauriAdapterOptions); open(bytes: Uint8Array, name?: string): Promise; sessionStatus(): Promise; /** Reconcile mutations performed outside this adapter (for example the embedded MCP control * server's `doc-changed` event) through the same authoritative revision comparison. */ refreshSessionStatus(): Promise; private syncRevision; pageCount(): Promise; pageSvg(page: number): Promise; hitTest(page: number, x: number, y: number): Promise; tableAt(page: number, x: number, y: number): Promise; /** Cell-level marking (issue 023) — the desktop `table_cell_at` (own-render px). Its `CellHitDto` * matches `CellHit` verbatim (`row`/`col` MODEL-GLOBAL); `null` off any cell (table border / merged * boundary → null, the caller falls back to whole-table). Same null policy as the wasm backend. */ tableCellAt(page: number, x: number, y: number): Promise; /** Image click-select (issue 049) — the desktop `image_at` command (crates/hwp-viewer, delegates to * `hwp_session::image_at`). Its `ImageBoxDto` (`{x,y,w,h,section,block}`) matches `ImageBox` verbatim; * `null` off any image (018 null policy) — SAME shape + null policy as the wasm `imageAt` binding, so * both backends drive the ImageOverlay identically (043 homomorphic parity). */ imageAt(page: number, x: number, y: number): Promise; /** Image box by anchor (issue 049) — the desktop `image_bbox` command (delegates to * `hwp_session::image_bbox`). Re-queried after a move/resize commit to re-place the overlay + * apply-verify; `null` when that image isn't on `page`. Matches the wasm `imageBbox` binding verbatim. */ imageBbox(page: number, section: number, block: number): Promise; /** Marquee select (issue 021) — the desktop `blocks_in_rect` (own-render px rect). Returns a * `BlockHit[]`; the command yields an EMPTY array on a miss / out-of-range page (never null), matching * the wasm backend's "[]"-on-miss policy — so the workspace enables marquee for this backend too. */ blocksInRect(page: number, x0: number, y0: number, x1: number, y1: number): Promise; /** Column-resize geometry (issue 027) — the desktop `table_col_boundaries`: `cols + 1` absolute px * x's (own-render px), or `null` when the table isn't on `page`. */ tableColBoundaries(page: number, section: number, block: number): Promise; /** Row-resize geometry (issue 031) — the desktop `table_row_boundaries`: `rows + 1` absolute px y's * (own-render px), the per-page FRAGMENT's boundaries for a split table, or `null` when off `page`. */ tableRowBoundaries(page: number, section: number, block: number): Promise; /** Ruler geometry (issue 027) — the desktop `page_geometry`: the page box + printable-area margins * (own-render px), or `null` when `page` is out of range. Its `PageGeom` matches verbatim. */ pageGeometry(page: number): Promise; /** Run-style read for run-preserving edits (issue 027 §함정) — the desktop `get_block_runs`: the * CURRENT styled runs of the `(row, col)` cell of the table at `(section, block)`, or of the paragraph * when `row`/`col` are omitted. `RunDto` matches `RunSpec`. `row`/`col` are passed as `null` (→ the * op-bus's paragraph target) when absent, mirroring the wasm binding's `row ?? null`. */ blockRuns(section: number, block: number, row?: number, col?: number): Promise; /** Nested-cell styled-run read (issue #64 D0) — the `BlockRunsPath` Intent through the GENERAL * `apply_intent_json` command (same op-bus the wasm `blockRunsPath` binding calls). Empty array * when the path does not resolve. No new Tauri command. */ blockRunsPath(section: number, path: CellAddr[]): Promise; /** Table cell GRID (issue #64 D0) — the `TableGrid` Intent via the same general command. * `{kind:"tableGrid", grid}` matches `TableGrid` verbatim; `null` when the block is not a table * (018). Same `hwp_session::table_grid` the wasm binding uses. */ tableGrid(section: number, block: number): Promise; /** Document profile (issue #64 D0) — the `DocProfile` Intent via the same general command. * `{kind:"docProfile", profile}` matches `DocProfile` verbatim (pure model read, no typeset). */ docProfile(): Promise; /** Document outline (issue 046) — the desktop `doc_outline` command (crates/hwp-viewer, delegates to * `hwp_session::outline`). Its `OutlineItem` DTO (`{section, block, level, text, page}`) matches the * wasm binding verbatim, and the command returns a `Vec` (an EMPTY ARRAY on an empty doc, never null — * 018), so both backends hand `HwpWorkspace` the SAME shape (043 homomorphic parity). */ outline(): Promise; /** WYSIWYG GLYPH caret (engine half) — the desktop `hit_test` command (crates/hwp-viewer, same rhwp * glyph-box `Intent::HitTest` the wasm path uses). Returns `null` off any glyph (018 null policy). * The command answers in camelCase; remap it to editor-core's snake_case `HitResult` so both * backends return ONE shape. `node`/`block` are null for cell text / an unanchored .hwp paragraph. */ hitTestText(page: number, x: number, y: number): Promise; /** WYSIWYG GLYPH caret (geometry half) — the desktop `caret_rect` command. Its DTO already matches * `CaretRect` ({x, top, height}); `null` when the paragraph isn't on `page` (a past-end offset is * clamped by the engine, never null). */ caretRect(page: number, node: number, offset: number): Promise; /** Cell-addressed caret, hit half (issue 053) — the `HitTestCell` Intent through the GENERAL * `apply_intent_json` command (the same op-bus dispatch the wasm applyIntent lane runs). The * `{kind:"hitCell", hit}` outcome carries hwp-session's `CellTextHitDto` verbatim (snake_case — * no remap; 043 homomorphic parity with the wasm binding). `null` off any cell text (018). */ hitTestCellText(page: number, x: number, y: number): Promise; /** Cell-addressed caret, geometry half (issue 053) — the `CaretRectCell` Intent via the same general * command; `{kind:"caretCell", caret}` matches `CellCaretRect` verbatim. `null` on an unresolvable * address; a PAST-END offset CLAMPS (a rect, never null). */ caretRectCell(section: number, block: number, row: number, col: number, para: number, offset: number, path?: CellAddr[]): Promise; /** Find (issue 045) — the desktop `find_text` command (same op-bus `do_find` the wasm `Find` Intent * uses, so identical matches). Its `FindMatchDto` (node/start/len/section/block) matches `FindMatch` * verbatim — no remap. `caseSensitive`/`wholeWord` are the command's camelCase param keys. Read-only, * no undo unit. */ find(query: string, opts: FindOptions): Promise; /** Replace (issue 045) — the desktop `replace_text` command, ONE undo unit (all=false → the first match * in the doc). Its `ReplaceResult` ({replaced, pages}) matches editor-core's `ReplaceResult` verbatim. * Same run-preserving op-bus core as the wasm `Replace` Intent (040 교훈: no plain-text collapse). */ replace(query: string, replacement: string, opts: FindReplaceOptions): Promise; /** Apply one schema-v0 Intent through the desktop's GENERAL `apply_intent_json` command (issue 043) — * the SAME op-bus (`hwp_mcp::apply_intent_json`) the wasm backend dispatches. The whole schema is * covered (SetTableCellRuns / SetCellRangeFmt / ApplyContent / TableInsertRows / …), so no Intent * silently no-ops; the command returns the `{kind, …}` Outcome (wasm-identical) and rejects with the * typed op-bus error verbatim on a refused edit. */ applyIntent(intent: Intent): Promise; proposeIntents(intents: Intent[]): Promise; commitProposal(proposalId: string, expectedRevision: number): Promise; undo(): Promise; redo(): Promise; registerFont(family: string, bytes: Uint8Array): Promise; hasFont(): boolean; /** PDF export as BYTES via the desktop `export_pdf_bytes` (issue 043 — the byte twin of the app's * path-based save). Tauri serializes the `Vec` as a number array; wrap it back into a Uint8Array * so the workspace's `download()` gets the SAME shape the wasm backend returns. On a build without * `--features pdf` the command rejects with an actionable message (the workspace toasts it). */ exportPdf(): Promise; exportHtml(): Promise; /** Round-trip-safe HWPX as BYTES via the desktop `export_hwpx_bytes` (issue 043 — the byte twin of * the app's path save; reuses `hwp_mcp::export_bytes`). Same Uint8Array shape as the wasm backend. */ toHwpx(): Promise; dispose(): void; } //# sourceMappingURL=TauriAdapter.d.ts.map