@embedpdf/plugin-render 3.0.0-next.1 → 3.0.0-next.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,220 +1,4 @@
1
- import { EngineRenderPolicy, PageImageHandle, PageObjectNumber, PageRenderViewport } from "@embedpdf/core";
2
- import { Rect } from "@embedpdf/core-geometry";
3
- //#region src/paint-plan.d.ts
4
- /**
5
- * The demand a page HOST supplies through dependency inversion:
6
- * plugin-render defines the shape, producers fill it. The Stage's page
7
- * host knows the camera and supplies `visibleRect`/`velocity`; a
8
- * stage-less `<PageView>` supplies neither — absent `visibleRect` means
9
- * "assume the whole page is visible", which a thumbnail-sized demand
10
- * turns into "no tiles engage" by arithmetic, not configuration.
11
- */
12
- interface PageViewDemand {
13
- /** Desired device pixels across the page's unrotated content width. */
14
- desiredDeviceWidth: number;
15
- /** Visible page region — y-down page points. ABSENT = whole page. */
16
- visibleRect?: Rect;
17
- /** Scroll velocity in page points/s — prefetch direction bias only. */
18
- velocity?: {
19
- dx: number;
20
- dy: number;
21
- };
22
- }
23
- /**
24
- * One tile the layer should have in the DOM. `key` is the reconciliation
25
- * identity (stable across plan recomputes — keyed lists preserve the DOM
26
- * node, which IS the retention mechanism); `rect` is y-down page points
27
- * inside the unrotated content box; `z` stacks by resolution so arriving
28
- * sharper tiles occlude retained coarser ones per region.
29
- */
30
- interface TilePaintSource {
31
- key: string;
32
- scale: number;
33
- rect: Rect;
34
- z: number;
35
- handle: PageImageHandle;
36
- }
37
- /**
38
- * What a TileLayer paints right now. `paint` draws ONLY from resolved
39
- * rasters — retained generations live here until the release rules fire;
40
- * "loading" never reaches the DOM. `fetching` is diagnostic (badge/tests).
41
- */
42
- interface TilePaintPlan {
43
- /** Tiles engaged at all? False = the base rung fully covers demand. */
44
- engaged: boolean;
45
- paint: TilePaintSource[];
46
- /** Keys currently in flight (want-set members not yet resolved). */
47
- fetching: string[];
48
- /** Memoization stamp — a new object appears only when this changes. */
49
- stamp: string;
50
- }
51
- /** Resolved tiling configuration (renderPlugin options + defaults). */
52
- interface TilingConfig {
53
- /** Tile edge in device px. Default 512. */
54
- tileSize?: number;
55
- /**
56
- * Client pyramid used while the policy doesn't advertise `tiles`.
57
- * Default `[1, 2, 4, 8, 16, 32]` — ×2 aligned.
58
- */
59
- scales?: readonly number[];
60
- /**
61
- * Sharpness deficit (desired ÷ supplied-by-base) above which tiles
62
- * engage. Default 1.25 — small CSS upscales read fine; past that the
63
- * ladder cap is visible and the pyramid takes over.
64
- */
65
- engageAt?: number;
66
- /** Prefetch ring around the visible rect. */
67
- prefetch?: {
68
- /** Extra coverage per side, in fractions of the visible rect. Default 0.5. */
69
- margin?: number;
70
- /** Stretch the ring toward scroll direction. Default true. */
71
- velocityBias?: boolean;
72
- };
73
- /**
74
- * Hysteresis for LEVEL changes (a zoom settling between pyramid rungs):
75
- * tile fetches for a NEW level wait this long; pan-driven fetches at the
76
- * current level fire immediately. Default 150ms; 0 disables.
77
- */
78
- settleMs?: number;
79
- }
80
- //#endregion
81
- //#region src/types.d.ts
82
- /** Options for `renderPlugin()`. Tiling is capability + economics here;
83
- * WHICH view tiles is composition (mount a TileLayer per lens), and
84
- * WHETHER it engages is demand arithmetic — three levels, three owners. */
85
- interface RenderPluginOptions {
86
- tiling?: TilingConfig;
87
- }
88
- interface RenderPageOptions {
89
- /** Device px per PDF point (use the page transform's `renderScale`). */
90
- scale: number;
91
- /**
92
- * Bake annotations into the page bitmap. Default true. Pass false when an
93
- * <AnnotationLayer> owns annotation rendering, so they aren't painted twice
94
- * (once baked, once by the overlay).
95
- */
96
- includeAnnotations?: boolean;
97
- /** Abort the render (camera moved / layer unmounted). */
98
- signal?: AbortSignal;
99
- }
100
- /**
101
- * The two invalidation scopes — every pixel-changing fact is one of them:
102
- *
103
- * 'annotations' — only baked APPEARANCES changed (an annotation mutated, a
104
- * form widget re-baked). Base renders keep their pixels.
105
- * 'content' — the PAGE ITSELF changed (redaction applied, text edited).
106
- * Invalidates everything: no mutation can change base pixels
107
- * yet leave an annotated raster valid, so content strictly
108
- * contains annotations.
109
- */
110
- type InvalidateScope = 'content' | 'annotations';
111
- /**
112
- * Per-page versions of the two raster products a page has — base
113
- * (`includeAnnotations: false`) and annotated. Fed by the document event
114
- * stream (see effects.ts) and by the `invalidate` verb: a confirmed
115
- * pixel-changing fact — own or remote — bumps the touched pages, and anything
116
- * holding a rendered bitmap (a thumbnail rail) refetches.
117
- */
118
- interface RenderState {
119
- /** Base-raster versions — bumped by CONTENT facts (redaction, text edit). */
120
- readonly contentEpochs: Readonly<Record<PageObjectNumber, number>>;
121
- /** Appearance versions — bumped by ANNOTATION facts (annotations, form widgets). */
122
- readonly annotatedEpochs: Readonly<Record<PageObjectNumber, number>>;
123
- /**
124
- * Tile paint-plan wake-ups. The tile manager's state (fetch/painted/
125
- * retention) lives OUTSIDE the store — it holds live handles and abort
126
- * controllers — so resolutions bump this counter to make subscribed
127
- * layers recompute `tilePlan`. The value itself carries no meaning.
128
- */
129
- readonly paintVersions: Readonly<Record<PageObjectNumber, number>>;
130
- }
131
- type RenderAction = {
132
- type: 'INVALIDATE';
133
- scope: InvalidateScope;
134
- pons: readonly PageObjectNumber[];
135
- } | {
136
- type: 'PAINT_ADVANCED';
137
- pon: PageObjectNumber;
138
- };
139
- interface RenderCapability {
140
- /**
141
- * Render a page (by its durable pon) to an ENCODED image. Abortable. Encoded
142
- * output is identical for local & cloud and cheap over the wire (vs. raw RGBA).
143
- *
144
- * CONFORMS to the deployment policy's three-layer rule:
145
- * under a lattice the desired `scale` converts to the canonical ladder width
146
- * via `snapFullPageViewport`; under `continuous` it passes through exactly.
147
- * Same-key requests collapse in the plugin's raster store (singleflight +
148
- * LRU), so repeated asks inside one rung cost one engine call.
149
- */
150
- renderPage(pon: PageObjectNumber, options: RenderPageOptions): Promise<PageImageHandle>;
151
- /**
152
- * The identity of the raster `renderPage` would produce for these options —
153
- * canonical viewport + annotations flag + epoch, as one stable string.
154
- * Layers key their fetch effect on THIS instead of the raw scale: inside a
155
- * rung the key never changes (zoom 1.2→1.5 under a [1,2]-ish lattice is a
156
- * no-op — no refetch, no DOM churn); it changes exactly at rung crossings
157
- * and epoch bumps. Always available: the kernel materializes the policy on
158
- * `DocumentMeta` before the document publishes.
159
- */
160
- renderSourceKey(pon: PageObjectNumber, options: {
161
- scale: number;
162
- includeAnnotations?: boolean;
163
- }): string;
164
- /**
165
- * The canonical viewport a desired scale conforms to for this page —
166
- * width-kind on a lattice, the exact scale under `continuous`.
167
- */
168
- conformViewport(pon: PageObjectNumber, scale: number): PageRenderViewport;
169
- /** The document's advertised policy (sugar over `DocumentMeta.renderPolicy`). */
170
- renderPolicy(): EngineRenderPolicy;
171
- /**
172
- * The tile paint plan for a page under a host-supplied demand. Tiling is a
173
- * STRATEGY inside this plugin, not a sibling.
174
- * Memoized: the same object returns until the demand, an epoch, or a
175
- * tile resolution actually changes it, so layers can subscribe with
176
- * plain `Object.is`. Calling it schedules the want-set fetches (visible
177
- * first, prefetch ring after) — idempotent, store-deduped. Engagement
178
- * is pure arithmetic: it fires only when the policy's ladder caps the
179
- * base below the demand; a thumbnail-sized demand never engages.
180
- */
181
- tilePlan(pon: PageObjectNumber, demand: PageViewDemand, opts?: {
182
- includeAnnotations?: boolean;
183
- }): TilePaintPlan;
184
- /**
185
- * The painter's decode-boundary report: the `<img>` for this plan key
186
- * actually painted (onload). Retained coarser generations covered by
187
- * painted want-set tiles release on this signal — never on fetch
188
- * completion, which would flash during decode.
189
- */
190
- tilePainted(pon: PageObjectNumber, key: string): void;
191
- /** A lens unmounted its TileLayer: abort in-flight tile fetches and drop
192
- * the page's tile bookkeeping (resolved bytes stay cached). */
193
- releaseTiles(pon: PageObjectNumber): void;
194
- /**
195
- * Version of the raster the given options would produce. Key a long-lived
196
- * render on it: when it bumps, refetch. Base renders version on content
197
- * facts; annotated renders on content AND annotation facts. Bumps only on
198
- * CONFIRMED mutations — never optimistically — so a drag invalidates once,
199
- * at commit.
200
- */
201
- renderEpoch(pon: PageObjectNumber, includeAnnotations?: boolean): number;
202
- /**
203
- * Declare that page pixels changed — the open door for facts the built-in
204
- * event map doesn't know (a plugin's own mutation vocabulary: redaction,
205
- * text edit, anything third-party). Call at CONFIRMATION (after the engine
206
- * write resolves), never for optimistic previews — those belong in overlay
207
- * layers. `pons` omitted = every page; `scope` defaults to 'content'
208
- * (repaint everything) because a caller who doesn't say is safest repainted
209
- * fully. Redundant with a mapped engine event? Harmless — one extra refetch.
210
- */
211
- invalidate(opts?: {
212
- pons?: readonly PageObjectNumber[];
213
- scope?: InvalidateScope;
214
- }): void;
215
- }
216
- declare const RenderToken: import("@embedpdf/core").CapabilityToken<RenderCapability>;
217
- //#endregion
1
+ import { a as RenderPluginOptions, c as FullPageOptions, d as TilePaintSource, f as TilesOptions, i as RenderCapability, l as PageViewDemand, n as PaintSettings, o as RenderState, r as RenderAction, s as RenderToken, t as InvalidateScope, u as TilePaintPlan } from "./contract-CWPMd1OW.js";
218
2
  //#region src/render.plugin.d.ts
219
3
  /**
220
4
  * Document-scoped. The ONE policy consumer in the client stack: the doc-bind
@@ -229,5 +13,5 @@ declare const RenderToken: import("@embedpdf/core").CapabilityToken<RenderCapabi
229
13
  */
230
14
  declare const renderPlugin: (options?: RenderPluginOptions) => import("@embedpdf/core").PluginDef<RenderState, RenderAction, RenderCapability>;
231
15
  //#endregion
232
- export { type InvalidateScope, type PageViewDemand, type RenderCapability, type RenderPluginOptions, type RenderState, RenderToken, type TilePaintPlan, type TilePaintSource, type TilingConfig, renderPlugin };
16
+ export { type FullPageOptions, type InvalidateScope, type PageViewDemand, type PaintSettings, type RenderCapability, type RenderPluginOptions, type RenderState, RenderToken, type TilePaintPlan, type TilePaintSource, type TilesOptions, renderPlugin };
233
17
  //# sourceMappingURL=index.d.ts.map