import { AcEdOpenMode } from '@mlightcad/cad-simple-viewer'; import { AcDbOpenDatabaseErrorCode } from '@mlightcad/data-model'; import { ComputedRef, DeepReadonly, Ref } from 'vue'; /** * Reactive view of the active CAD document and its open lifecycle. * * Returned by {@link useDocument}. All refs are shared module singletons, so * every caller observes the same document state. */ export interface UseDocumentReturn { /** * Whether a document open operation is currently in progress. * * Becomes `true` when {@link AcApDocManager.events.documentToBeOpened} fires * or when {@link beginDocumentOpening} is called manually, and becomes * `false` when the document is activated, opening fails, or * {@link endDocumentOpening} is called manually. */ isDocumentOpening: DeepReadonly>; /** * Current or pending document access mode. * * During an open request this reflects the mode carried by * {@link AcDbDocumentEventArgs.mode} from `documentToBeOpened`. After * activation it mirrors {@link AcApDocument.openMode}. */ openMode: DeepReadonly>; /** * File name of the active document. * * Mirrors {@link AcApDocument.fileName}. Empty for a new untitled document * that has not been saved or opened from disk. */ fileName: DeepReadonly>; /** * Display title of the active document. * * Mirrors {@link AcApDocument.docTitle}. For a new document this is * {@link ACAP_UNTITLED_DOC_TITLE} until a file is opened. */ docTitle: DeepReadonly>; /** * User-facing document label for UI display. * * Resolves to {@link docTitle} when present, otherwise falls back to * {@link fileName}. When the document is unsaved, localizes * {@link ACAP_UNTITLED_DOC_TITLE} via `main.document.untitled`. */ displayName: ComputedRef; /** * Marks the viewer as entering a document open operation. * * Prefer relying on {@link AcApDocManager.events.documentToBeOpened} when * possible. Call this manually only for open flows that bypass the manager * events but still need UI affordances such as disabling the ribbon. */ beginDocumentOpening: () => void; /** * Marks the viewer as leaving a document open operation. * * Prefer relying on {@link AcApDocManager.events.documentActivated} or the * `failed-to-open-file` event. Call this manually to pair with * {@link beginDocumentOpening} in custom open handlers. */ endDocumentOpening: () => void; /** * Structured failure category from the most recent `failed-to-open-file` * event, when available. */ lastOpenErrorCode: DeepReadonly>; } /** * Tracks the active CAD document and its open lifecycle for UI consumers. * * This composable centralizes reactive document metadata from * {@link AcApDocManager} and {@link AcApDocument}, including: * - Current or pending document open mode * - Whether a document open operation is in progress * - Current document file name and display title * * Behavior: * - Initializes from the currently active document once the viewer exists * - Retries binding after mount when the viewer has not been created yet * - Updates {@link openMode} as soon as `documentToBeOpened` fires * - Synchronizes {@link fileName}, {@link docTitle}, and {@link openMode} * when `documentActivated` fires * - Clears the opening state when `failed-to-open-file` is emitted * - Records {@link lastOpenErrorCode} from structured open failures * * @returns Shared reactive document state and manual open-state helpers */ export declare function useDocument(): UseDocumentReturn; //# sourceMappingURL=useDocument.d.ts.map