Initialize the Viewer
Mount the NPM SDK viewer, open a document, and drive host loading UI from document events.
Create the viewer with a host element, then wait for both viewer.mount() and viewer.ready() before opening a document or enabling document controls.
Subscribe before calling viewer.documents.open(...). Show the progress bar while the request is pending. fileReady is the authoritative confirmation that the file is open and active; hide the progress bar only then. fileLoadFailed is the Canvas-side failure path: hide the progress bar, retain the input, and present a retry action.
Start the pending UI before the call. The open(...) promise provides the request result, while fileReady and fileLoadFailed keep the host UI synchronized with Canvas file state.
Call every unsubscribe function and destroy the viewer when the host route or component unmounts. This prevents a previous route from changing the current route’s loading state.
