{"version":3,"file":"contract-q-KJ295G.cjs","names":[],"sources":["../src/paint-plan.ts","../src/token.ts","../src/contract.ts"],"sourcesContent":["import type { PageImageHandle } from '@embedpdf/core';\nimport type { Rect } from '@embedpdf/core-geometry';\n\n/**\n * The demand a page host supplies through dependency inversion:\n * plugin-render defines the shape, producers fill it. The Stage's page\n * host knows the camera and supplies `visibleRect`/`velocity`; a\n * stage-less `<PageView>` supplies neither — absent `visibleRect` means\n * \"assume the whole page is visible\", which a thumbnail-sized demand\n * turns into \"no tiles engage\" by arithmetic, not configuration.\n */\nexport interface PageViewDemand {\n  /** Desired device pixels across the page's unrotated content width. */\n  desiredDeviceWidth: number;\n  /** Visible page region — y-down page points. Absent means the whole page. */\n  visibleRect?: Rect;\n  /** Scroll velocity in page points/s — prefetch direction bias only. */\n  velocity?: { dx: number; dy: number };\n}\n\n/**\n * Whether two demands ask for the same thing. A host builds a new demand object on every camera\n * frame; a layer that compares with this sets it again (and plans again) only when it changed.\n */\nexport function samePageViewDemand(left: PageViewDemand, right: PageViewDemand): boolean {\n  return (\n    left.desiredDeviceWidth === right.desiredDeviceWidth &&\n    left.velocity?.dx === right.velocity?.dx &&\n    left.velocity?.dy === right.velocity?.dy &&\n    (left.visibleRect === right.visibleRect ||\n      (left.visibleRect !== undefined &&\n        right.visibleRect !== undefined &&\n        left.visibleRect.x === right.visibleRect.x &&\n        left.visibleRect.y === right.visibleRect.y &&\n        left.visibleRect.width === right.visibleRect.width &&\n        left.visibleRect.height === right.visibleRect.height))\n  );\n}\n\n/**\n * One tile the layer should have in the DOM. `key` is the reconciliation\n * identity (stable across plan recomputes — keyed lists preserve the DOM\n * node, which is the retention mechanism); `rect` is y-down page points\n * inside the unrotated content box; `z` stacks by resolution so arriving\n * sharper tiles occlude retained coarser ones per region.\n */\nexport interface TilePaintSource {\n  key: string;\n  scale: number;\n  rect: Rect;\n  z: number;\n  handle: PageImageHandle;\n}\n\n/**\n * What a tile plane paints right now. `paint` draws only from resolved\n * rasters — retained generations live here until the release rules fire;\n * \"loading\" never reaches the DOM. `fetching` is diagnostic (badge/tests).\n */\nexport interface TilePaintPlan {\n  /** Tiles engaged at all? False = the base rung fully covers demand. */\n  engaged: boolean;\n  paint: TilePaintSource[];\n  /** Keys currently in flight (want-set members not yet resolved). */\n  fetching: string[];\n  /** Memoization stamp — a new object appears only when this changes. */\n  stamp: string;\n}\n\nexport const EMPTY_TILE_PLAN: TilePaintPlan = {\n  engaged: false,\n  paint: [],\n  fetching: [],\n  stamp: 'empty',\n};\n\n/**\n * The base-plane strategy: the pixel budget and the render points below it.\n * Device px throughout (CSS px × devicePixelRatio).\n */\nexport interface FullPageSettings {\n  /**\n   * The budget: no full-page raster ever renders wider. Small by design —\n   * the base is the instant backdrop; sharpness past it is the tile plane's\n   * job. Default 640.\n   */\n  maxWidth?: number;\n  /**\n   * Render points under a `continuous` policy. `'exact'` (default) renders\n   * the settled demand precisely — resting pixels are never resampled, the\n   * only way ~1px text stems stay crisp on dpr-1 screens. A width ladder\n   * opts into rung caching instead (defensible on dpr≥2 embeds). An\n   * advertised deployment lattice always wins over either.\n   */\n  quantize?: 'exact' | readonly number[];\n}\n\n/** The tile-plane strategy. Pass `tiles: false` to disable the plane. */\nexport interface TilesSettings {\n  /** Tile edge in device px. Default 512 (policy `tileSizes` win when advertised). */\n  size?: number;\n  /**\n   * Tile levels under a `continuous` policy: `'exact'` (default) renders the\n   * settled scale precisely; a scale ladder opts into pyramid reuse. An\n   * advertised `policy.tiles` block always wins.\n   */\n  quantize?: 'exact' | readonly number[];\n  /**\n   * Exact-mode safety clamp on the tile level (device px per point) — the\n   * sharpness ceiling. Past `maxScale × pageWidth` device px of demand,\n   * tiles CSS-stretch instead of re-rendering. Per-screen tile cost is\n   * constant at any level, so this bounds nothing but numeric range.\n   * Default 128 (≈ 6,400% zoom on a letter page at dpr 2).\n   */\n  maxScale?: number;\n  /**\n   * Overlap neighboring tiles by this many device pixels per shared edge\n   * (each tile renders a slightly larger region and is placed to match).\n   * Kills hairline seams whenever tiles display at anything other than 1:1 —\n   * separate `<img>`s at fractional boundaries each get partial-coverage\n   * edge anti-aliasing, and bilinear scaling smears their last row — by\n   * making every edge land over the neighbor's identical content instead of\n   * the backdrop. Default 1; 0 disables.\n   */\n  bleedPx?: number;\n  /**\n   * Sharpness deficit (desired ÷ supplied-by-base) above which tiles engage.\n   * Resolved default: 1.0 when the base is exact (nothing may rest\n   * stretched), 1.25 under a lattice.\n   */\n  engageRatio?: number;\n  /** Prefetch ring around the visible rect. */\n  prefetch?: {\n    /** Extra coverage per side, in fractions of the visible rect. Default 0.5. */\n    margin?: number;\n    /** Stretch the ring toward scroll direction. Default true. */\n    velocityBias?: boolean;\n  };\n  /**\n   * Settle gate for level changes (a zoom in motion): tile fetches for a new\n   * level wait this long; pan-driven fetches at the current level fire\n   * immediately. Default 150ms; 0 disables.\n   */\n  settleMs?: number;\n}\n\n/** The default pixel budget of a whole-page picture, in device pixels. */\nconst DEFAULT_BUDGET_PX = 640;\n\n/** The ×2 client pyramid used for lattice deployments without a tiles block. */\nexport const DEFAULT_TILE_PYRAMID: readonly number[] = [1, 2, 4, 8, 16, 32];\n\nexport interface ResolvedRenderOptions {\n  fullPage: {\n    maxWidth: number;\n    /** True when the embedder set maxWidth themselves — only then does it\n     *  also filter an advertised deployment ladder (the mobile-memory\n     *  knob); the default budget governs the client's own strategy only. */\n    maxWidthExplicit: boolean;\n    quantize: 'exact' | readonly number[];\n  };\n  tiles: {\n    enabled: boolean;\n    size: number;\n    quantize: 'exact' | readonly number[];\n    maxScale: number;\n    bleedPx: number;\n    engageRatio: number | undefined;\n    prefetchMargin: number;\n    velocityBias: boolean;\n    settleMs: number;\n    /** Pyramid for lattice deployments that don't advertise tiles yet. */\n    fallbackPyramid: readonly number[];\n  };\n  format?: 'png' | 'webp' | 'bmp';\n  quality?: number;\n  /** Diagnostic logging (tile scheduling, fetch outcomes). */\n  debug: boolean;\n}\n\n/**\n * The settings as the strategy reads them, every value filled in. The base\n * budget filters an advertised deployment ladder only when the app chose a\n * width other than the default 640.\n */\nexport function resolveRenderOptions(options: {\n  fullPage?: FullPageSettings;\n  tiles?: TilesSettings | false;\n  format?: 'png' | 'webp' | 'bmp' | null;\n  quality?: number | null;\n  debug?: boolean;\n}): ResolvedRenderOptions {\n  const tiles = options.tiles === false ? undefined : options.tiles;\n  return {\n    fullPage: {\n      maxWidth: options.fullPage?.maxWidth ?? DEFAULT_BUDGET_PX,\n      maxWidthExplicit:\n        options.fullPage?.maxWidth !== undefined && options.fullPage.maxWidth !== DEFAULT_BUDGET_PX,\n      quantize: options.fullPage?.quantize ?? 'exact',\n    },\n    tiles: {\n      enabled: options.tiles !== false,\n      size: tiles?.size ?? 512,\n      quantize: tiles?.quantize ?? 'exact',\n      maxScale: tiles?.maxScale ?? 128,\n      bleedPx: tiles?.bleedPx ?? 1,\n      engageRatio: tiles?.engageRatio,\n      prefetchMargin: tiles?.prefetch?.margin ?? 0.5,\n      velocityBias: tiles?.prefetch?.velocityBias ?? true,\n      settleMs: tiles?.settleMs ?? 150,\n      fallbackPyramid: DEFAULT_TILE_PYRAMID,\n    },\n    format: options.format ?? undefined,\n    quality: options.quality ?? undefined,\n    debug: options.debug ?? false,\n  };\n}\n","/** The package token — created once here; `contract.ts` re-exports it and\n *  `host-contract.ts` widens it. */\nimport { createCapabilityToken } from '@embedpdf/core';\n\nimport type { RenderCapability } from './contract';\n\nexport const RenderToken = createCapabilityToken<RenderCapability>('render', {\n  hint: `add renderPlugin() from '@embedpdf/plugin-render' to your plugins list`,\n  // Without a document, an adapter's stand-in rejects these with `not-ready`, as the\n  // capability would; the type asks for every member that returns a promise.\n  promises: {\n    renderPage: true,\n    renderThumbnail: true,\n    renderPages: true,\n  },\n});\n","/**\n * @embedpdf/plugin-render/contract — the public render vocabulary.\n *\n * Page rasters for developers: exact-size renders, thumbnails, batches, the\n * deployment's render policy, and invalidation (both directions: the\n * `invalidate` verb in, `onInvalidated` out). Everything a view layer needs\n * to paint (conformed source keys, tile plans) is the host lens,\n * `@embedpdf/plugin-render/contract/host`.\n */\nimport {\n  type BatchResult,\n  type DeepPartial,\n  type EngineRenderPolicy,\n  type EventHook,\n  type EventOrigin,\n  type OperationOptions,\n  type PageImageHandle,\n  type PageImageOptions,\n  type PageRef,\n  type ResourceStatus,\n  type SettingsApi,\n} from '@embedpdf/core';\nimport type { Rotation, PageTransform, Rect } from '@embedpdf/core-geometry';\nimport type { FullPageSettings, PageViewDemand, TilesSettings } from './paint-plan';\n\nexport type { FullPageSettings, PageViewDemand, TilesSettings } from './paint-plan';\nexport { samePageViewDemand } from './paint-plan';\n\n// ── settings ────────────────────────────────────────────────────────────────\n\n/** Encode format the engine can produce for a raster. */\nexport type RenderFormat = NonNullable<PageImageOptions['format']>;\n\n/**\n * The render strategy: what the viewer chooses to spend, and which render\n * points it uses when the engine permits anything. The shape mirrors the\n * deployment policy (`policy.fullPage` / `policy.tiles`), and the one\n * composition rule is: a strategy value applies as written under a\n * `continuous` policy, and the advertised lattice wins when there is one,\n * so the same settings run unchanged against local and cloud. They belong to\n * the plugin as registered: `updateSettings()` changes every document.\n */\nexport interface RenderSettings {\n  /** Base plane: the pixel budget + render points. */\n  readonly fullPage: FullPageSettings;\n  /** Tile plane strategy; `false` disables the plane entirely. */\n  readonly tiles: TilesSettings | false;\n  /**\n   * Encode format for both planes. `null` → engine default (png local, the\n   * deployment's format on cloud). `'bmp'` is the local fast path — no\n   * compression, no encoder-worker round trip; under a lattice it conforms\n   * to `policy.formats`.\n   */\n  readonly format: RenderFormat | null;\n  /** WebP quality from 0 (smallest) to 1 (best); PNG and BMP ignore it. `null` → the engine's. */\n  readonly quality: number | null;\n  /**\n   * How long a page waits for its first picture before its state turns `slow`, in milliseconds:\n   * the moment to show a loading indicator ({@link PictureState}). `0` turns it on at once.\n   */\n  readonly slowAfterMs: number;\n  /** Diagnostic logging of tile scheduling and fetch outcomes (console `debug`). */\n  readonly debug: boolean;\n  /** The `snapshot` tool: how big its pictures are, and how its box looks. */\n  readonly snapshot: SnapshotSettings;\n}\n\n/** The snapshot tool's settings: see {@link RenderSettings.snapshot}. */\nexport interface SnapshotSettings {\n  /**\n   * A snapshot's pixels per point: 2 is 144 DPI. A picture that would pass\n   * {@link SNAPSHOT_MAX_PIXELS}, or the deployment's budget, is made smaller to fit.\n   */\n  readonly scale: number;\n  /**\n   * The look of the box you drag, one value: a change replaces it whole, and a\n   * color it leaves out is `null` again. A color left `null` follows the\n   * viewer's accent (the fill at 8%); CSS `--epdf-snapshot-box-fill` and\n   * `--epdf-snapshot-box-stroke` win over both.\n   */\n  readonly box: SnapshotBoxLook;\n}\n\n/** The colors of the snapshot tool's box: see {@link SnapshotSettings.box}. */\nexport interface SnapshotBoxLook {\n  /** Inside the box; `null` is the viewer's accent at 8%. */\n  readonly fill: string | null;\n  /** Its dashed edge; `null` is the viewer's accent. */\n  readonly stroke: string | null;\n}\n\n/** The most pixels a snapshot's picture has: 16 million, safe within a phone's memory. */\nexport const SNAPSHOT_MAX_PIXELS = 16_000_000;\n\n/** What the render settings are when the app registers none. */\nexport const RENDER_DEFAULTS: RenderSettings = {\n  fullPage: { maxWidth: 640, quantize: 'exact' },\n  tiles: {\n    size: 512,\n    quantize: 'exact',\n    maxScale: 128,\n    bleedPx: 1,\n    prefetch: { margin: 0.5, velocityBias: true },\n    settleMs: 150,\n  },\n  format: null,\n  quality: null,\n  slowAfterMs: 400,\n  debug: false,\n  snapshot: { scale: 2, box: { fill: null, stroke: null } },\n};\n\n/** What `renderPlugin(config)` takes: any of the settings, merged over the defaults. */\nexport type RenderConfig = DeepPartial<RenderSettings>;\n\n// ── the raster vocabulary ───────────────────────────────────────────────────\n\n/**\n * What a picture draws beside the page content. An option left out draws\n * what the user may read: the annotations with `doc.annotate.read`, the form\n * fields with `doc.forms.read`, and no form fields when `includeAnnotations`\n * is `false`. `true` for something the user may not read is refused\n * (`permission-denied`). Leave out what you paint yourself: a layer that\n * paints annotations passes `includeAnnotations: false`, which leaves the\n * form fields out too unless you ask for them (`includeFormFields: true`).\n */\nexport interface PageLayerOptions {\n  /** Draw the annotations (form fields' widgets excepted). */\n  includeAnnotations?: boolean;\n  /** Draw the form fields, each in the state its field shows. */\n  includeFormFields?: boolean;\n}\n\n/**\n * An encoded page image: `source` is bytes or a URL, `format`/`mimeType`\n * say what they are, `width`/`height` its pixel size, and\n * `objectUrl()` mints a revocable object URL for an `<img>`.\n */\nexport type PageImage = PageImageHandle;\n\nexport interface RenderPageOptions extends OperationOptions, PageLayerOptions {\n  /** Exact output width in device pixels (height keeps the aspect of what is drawn). */\n  width?: number;\n  /** Device pixels per PDF point; ignored when `width` is given. Default 1. */\n  scale?: number;\n  /**\n   * Draw only this part of the page, in page space: from the page's top-left,\n   * y down, in points. `width` and `scale` then size the part. Cut at the\n   * page's edge; a rect that misses the page is refused (`invalid-input`).\n   */\n  rect?: Rect;\n  /** Turn the picture clockwise. Default 0: the page as stored. */\n  rotation?: Rotation;\n  /** Per-call encode overrides; default to the plugin's strategy. */\n  format?: RenderFormat;\n  quality?: number;\n}\n\nexport interface RenderThumbnailOptions extends OperationOptions, PageLayerOptions {\n  /** Per-call encode overrides; default to the plugin's strategy. */\n  format?: RenderFormat;\n  quality?: number;\n}\n\n/** A batch renders whole pages: the options of {@link RenderPageOptions} but a `rect`. */\nexport interface RenderPagesOptions extends Omit<RenderPageOptions, 'rect'> {\n  /** Renders in flight at once (default 4). */\n  concurrency?: number;\n}\n\n/** One entry of a batch render. */\nexport interface PageRender {\n  readonly page: PageRef;\n  readonly image: PageImage;\n}\n\n/**\n * The invalidation scopes — every pixel-changing fact is one of them:\n *\n *   'annotations' — an annotation changed. Pictures without annotations keep\n *                   their pixels.\n *   'fields'      — a form field changed: a fill, a widget's place or look,\n *                   a signing. Pictures without form fields keep their pixels.\n *   'content'     — the page itself changed (redaction applied, flattened).\n *                   Invalidates every picture of the page.\n */\nexport type InvalidateScope = 'content' | 'annotations' | 'fields';\n\nexport interface InvalidateOptions {\n  /** The pages whose pixels changed, by ref or index; omitted = every page. */\n  pages?: readonly (PageRef | number)[];\n  /** Defaults to `'content'` — a caller who doesn't say is safest repainted fully. */\n  scope?: InvalidateScope;\n}\n\n// ── events ──────────────────────────────────────────────────────────────────\n\n/** Pixels changed on these pages: a confirmed document mutation (own or\n *  remote) or an `invalidate` call. Anything holding a rendered bitmap refetches. */\nexport interface RenderInvalidatedEvent {\n  readonly pages: readonly PageRef[];\n  readonly scope: InvalidateScope;\n  /**\n   * Where the document mutation came from. Null when a caller requested the\n   * invalidation through {@link RenderCapability.invalidate}.\n   */\n  readonly origin: EventOrigin | null;\n}\n\n// ── snapshots ───────────────────────────────────────────────────────────────\n\n/** The tool that takes snapshots: drag a box on a page, or click for the whole page. */\nexport const SNAPSHOT_TOOL = 'snapshot';\n\n/**\n * Part of a page taken as a picture with the {@link SNAPSHOT_TOOL}: held\n * until another is taken, the tool changes or it is let go\n * ({@link RenderCapability.clearSnapshot}).\n */\nexport interface Snapshot {\n  /** The page it was taken on. */\n  readonly page: PageRef;\n  /** The box, in page space: from the page's top-left, y down, in points. */\n  readonly rect: Rect;\n  /**\n   * Its picture, as PNG, turned as the page was shown. Rejects when it can't be\n   * rendered, and with `operation-cancelled` once the snapshot is let go first.\n   */\n  readonly image: Promise<PageImage>;\n}\n\n/** A snapshot was taken, or let go (`snapshot: null`). */\nexport interface SnapshotChangedEvent {\n  readonly snapshot: Snapshot | null;\n}\n\n// ── whether a page's picture is on screen ───────────────────────────────────\n\n/**\n * Whether a picture of a page is on screen in a view ({@link RenderCapability.getPictureState}).\n * Only the first picture counts: tiles arriving as the view zooms in, and a redraw after a\n * change, keep the old picture on screen, so the page stays `ready`.\n */\nexport interface PictureState {\n  /**\n   * `idle`: the view doesn't show the page. `loading`: it does, and no picture of the page is on\n   * screen yet. `ready`: one is. `forbidden`: the user may not see it (no `doc.render`).\n   * `error`: it couldn't be drawn.\n   */\n  readonly status: ResourceStatus;\n  /** Loading for longer than `slowAfterMs`: the moment to show an indicator. */\n  readonly slow: boolean;\n}\n\n/** A page's picture came on screen, failed, went slow, or the page left the view. */\nexport interface PictureStateChangedEvent extends PictureState {\n  readonly page: PageRef;\n  readonly view: string;\n}\n\n/**\n * What paints a page's picture tells the render plugin, so the page's {@link PictureState}\n * knows: the page layers say it for the plugin's own pictures, a {@link PicturePainter} for its.\n */\nexport interface PictureReport {\n  /** A picture of the page is on screen now: it has been presented. */\n  shown(): void;\n  /**\n   * The picture can't be painted, and why: a `permission-denied` error makes the page\n   * `forbidden`, any other `error`. Ignored once a picture showed, which stays on screen.\n   */\n  failed(error: unknown): void;\n}\n\n// ── another plugin painting the pictures ────────────────────────────────────\n\n/**\n * The page a painter paints, as every framework's page layer knows it: a\n * subset of `@embedpdf/web`'s page context, the same in each framework.\n */\nexport interface PicturePage {\n  /** The page's address, the same for as long as the page is shown. */\n  readonly ref: PageRef;\n  /** Its place in the document, from 0. */\n  readonly pageIndex: number;\n  /** The view that shows it: a Stage's lens id. */\n  readonly view: string;\n  /** Its size, zoom and turn on screen, and its device pixels. */\n  readonly transform: PageTransform;\n  /** The part of it on screen, read when asked; absent for a view without a camera. */\n  readonly getViewDemand?: () => PageViewDemand;\n}\n\n/** A picture a painter is painting: follow the page as it changes, and stop. */\nexport interface PaintedPicture {\n  /** The page's geometry changed (a zoom, a turn, a resize): `page` is how it is now. */\n  update(page: PicturePage): void;\n  /** The page left its view, or the painter was given back: take the picture away. */\n  destroy(): void;\n}\n\n/**\n * Something that paints the pages' pictures instead of the render plugin\n * ({@link RenderCapability.handOverPictures}). `Host` is the box a page layer\n * lends it: an `HTMLElement` on the web.\n */\nexport interface PicturePainter<Host = unknown> {\n  /** Whether it paints the pictures of this view; a view it doesn't paint keeps the render plugin's. */\n  paints(view: string): boolean;\n  /**\n   * Paint `page`'s picture into `host`, an empty box over the page's content, until `destroy()`.\n   * The page is `loading` until `report.shown()`: call it once the first picture is on screen.\n   */\n  paint(host: Host, page: PicturePage, report: PictureReport): PaintedPicture;\n}\n\n// ── the public capability ───────────────────────────────────────────────────\n\nexport interface RenderCapability extends SettingsApi<RenderSettings> {\n  /**\n   * Would page rasters be served to this session (`doc.render`)? When false\n   * every render refuses locally with `permission-denied` — no doomed engine\n   * round-trips — and a host can show its \"no preview\" state instead.\n   */\n  canRender(): boolean;\n  /**\n   * May this session have the pages' thumbnails (`doc.render.thumbnail`,\n   * which `doc.render` includes)? A session that may not render pages may\n   * still have them.\n   */\n  canRenderThumbnail(): boolean;\n  /**\n   * Render one page, by its ref or its index, at the requested size. The\n   * size is honoured exactly (nothing is snapped to the viewer's render\n   * points); the shared raster cache serves the call when it already holds a\n   * matching image. A part of the page (`rect`) or a turned picture is\n   * rendered for this call alone, outside the cache. Rejects\n   * `permission-denied` without `doc.render`, `not-found` for a page that is\n   * not in this document, `invalid-input` for a `rect` that misses the page,\n   * `operation-cancelled` when `signal` fires.\n   */\n  renderPage(page: PageRef | number, options?: RenderPageOptions): Promise<PageImage>;\n  /**\n   * The page's thumbnail: the whole page, `PAGE_THUMBNAIL_SIZE` (512) pixels\n   * on its long side, sharing the raster cache. Needs only\n   * `doc.render.thumbnail`; rejects `permission-denied` without it, otherwise\n   * like `renderPage`.\n   */\n  renderThumbnail(page: PageRef | number, options?: RenderThumbnailOptions): Promise<PageImage>;\n  /**\n   * Render several pages with bounded concurrency; best-effort per page: each\n   * rendered page with its image, in the order given, and each page that\n   * failed (as given) with why. Rejects `permission-denied` without\n   * `doc.render`, `operation-cancelled` when `signal` fires.\n   */\n  renderPages(\n    pages: readonly (PageRef | number)[],\n    options?: RenderPagesOptions,\n  ): Promise<BatchResult<PageRender, PageRef | number>>;\n  /** The deployment's advertised render policy (a document fact). */\n  getRenderPolicy(): EngineRenderPolicy;\n  /**\n   * The version of the picture the given options would produce. Key a\n   * long-lived render on it: when it bumps, refetch. A picture versions on\n   * content facts, plus annotation facts when it draws annotations and form\n   * facts when it draws form fields. Bumps only on confirmed mutations —\n   * never optimistically. 0 for a page that isn't in the document.\n   */\n  getRenderEpoch(page: PageRef | number, layers?: PageLayerOptions): number;\n  /**\n   * Declare that page pixels changed — the open door for facts the built-in\n   * event map doesn't know (a plugin's own mutation vocabulary, anything\n   * third-party). Call at confirmation, never for optimistic previews.\n   * Fires `onInvalidated`; a page that isn't in the document is skipped.\n   */\n  invalidate(options?: InvalidateOptions): void;\n  /** Pages' pixels changed and they will redraw. */\n  readonly onInvalidated: EventHook<RenderInvalidatedEvent>;\n  /**\n   * Whether a picture of the page is on screen in `view` (a page context's `view`): `loading`\n   * until one is, and `slow` once it waited `slowAfterMs`. The same object while it's the same;\n   * `idle` for a page that isn't in the document.\n   */\n  getPictureState(page: PageRef | number, view: string): PictureState;\n  /** A page's {@link PictureState} changed in a view. */\n  readonly onPictureStateChanged: EventHook<PictureStateChangedEvent>;\n  /**\n   * Let another plugin paint the pages' pictures until the returned function\n   * is called, or the document closes. While it holds them, every page layer\n   * in a view it paints lends it its box instead of drawing: no picture, no\n   * tiles, no renders. One painter at a time: a second is refused\n   * (`conflict`) until the first is given back. Take them over in a plugin's\n   * `connect()`, and no page shows this plugin's picture first.\n   */\n  handOverPictures<Host>(painter: PicturePainter<Host>): () => void;\n  /** The plugin painting the pictures now, or `null` while this one does. */\n  getPicturePainter(): PicturePainter | null;\n  /**\n   * May this session take snapshots? It needs `doc.render` and\n   * `doc.content.copy`, which a PDF that forbids copying leaves out. Without\n   * them the {@link SNAPSHOT_TOOL} draws no box.\n   */\n  canSnapshot(): boolean;\n  /** The snapshot held now, or `null`: the same object while it is held. */\n  getSnapshot(): Snapshot | null;\n  /** Let the snapshot go; its picture, if still rendering, stops. */\n  clearSnapshot(): void;\n  /** A snapshot was taken, or let go. */\n  readonly onSnapshotChanged: EventHook<SnapshotChangedEvent>;\n}\n\nexport { RenderToken } from './token';\n\n// Re-exported for hosts that describe what a view wants (`PageContext.getViewDemand`).\nexport type { PageViewDemand as ViewDemandInput };\n"],"mappings":";;;;;;AAwBA,SAAgB,mBAAmB,MAAsB,OAAgC;CACvF,OACE,KAAK,uB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