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. SDK 2.2.1 adds optional readiness timeout and cancellation controls; existing await viewer.ready() usage remains valid.
Pass timeoutMs to override the 60-second default readiness timeout. If Canvas does not become ready in time, the promise rejects with CANVAS_READY_TIMEOUT.
Pass an AbortSignal through signal to cancel readiness. A cancelled readiness promise rejects with VIEWER_NOT_READY. Both options can be used together, and they affect NPM SDK readiness only; no Canvas-side change is required.
timeoutMsis optional. The default is60_000milliseconds.signalis optional and accepts anAbortSignal.await viewer.ready()without options remains supported.
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.
