import { CONTINUOUS_RENDER_POLICY, LOCAL_ENGINE_BRAND, type EngineRenderPolicy, type LocalPageHandle as LocalPageHandleContract, type PageObjectNumber, type PageRef, type DocumentPagesService, type SessionEventPublisher, } from '@embedpdf/engine-core/runtime'; import { LocalPageAnnotationsService } from './LocalPageAnnotationsService'; import { LocalPageFormsService } from './LocalPageFormsService'; import { LocalPageRenderService } from './LocalPageRenderService'; import { LocalPageTextService } from './LocalPageTextService'; import { LocalPieceInfoService } from './LocalPieceInfoService'; import { LocalPageMeasureService } from './LocalPageMeasureService'; import type { LocalImageEncoder } from '../render/BrowserImageEncoder'; import type { ScopeGuard } from '../scope'; import type { JobQueue } from '../worker/WorkerQueue'; interface DocClosedView { isClosed(): boolean; } /** * Local page handle: the page's address and its services. The per-page * services each own their queue interaction; the handle is otherwise * stateless. */ export class LocalPageHandle implements LocalPageHandleContract { readonly [LOCAL_ENGINE_BRAND] = true; readonly annotations: LocalPageAnnotationsService; readonly forms: LocalPageFormsService; readonly text: LocalPageTextService; readonly render: LocalPageRenderService; readonly pieceInfo: LocalPieceInfoService; readonly measure: LocalPageMeasureService; constructor( readonly ref: PageRef, docId: string, queue: JobQueue, view: DocClosedView, imageEncoder: LocalImageEncoder, guard: ScopeGuard, publisher: SessionEventPublisher, setScale: DocumentPagesService['setScale'], renderPolicy: EngineRenderPolicy = CONTINUOUS_RENDER_POLICY, ) { this.annotations = new LocalPageAnnotationsService( docId, ref, queue, view, imageEncoder, guard, publisher, renderPolicy, ); this.forms = new LocalPageFormsService( docId, ref, queue, view, imageEncoder, guard, renderPolicy, ); this.text = new LocalPageTextService(docId, ref, queue, view, guard); this.render = new LocalPageRenderService( docId, ref, queue, view, imageEncoder, guard, renderPolicy, ); this.pieceInfo = new LocalPieceInfoService(docId, queue, view, guard, ref); this.measure = new LocalPageMeasureService(docId, ref, queue, view, guard, setScale); } }