@embedpdf/plugin-render 3.0.0-next.1 → 3.0.0-next.10
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.cjs +477 -152
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +166 -53
- package/dist/index.d.ts +166 -53
- package/dist/index.js +478 -153
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EngineRenderPolicy, PageImageHandle, PageObjectNumber, PageRenderViewport } from "@embedpdf/core";
|
|
1
|
+
import { EngineRenderPolicy, PageImageHandle, PageImageOptions, PageObjectNumber, PageRenderViewport } from "@embedpdf/core";
|
|
2
2
|
import { Rect } from "@embedpdf/core-geometry";
|
|
3
3
|
//#region src/paint-plan.d.ts
|
|
4
4
|
/**
|
|
@@ -35,7 +35,7 @@ interface TilePaintSource {
|
|
|
35
35
|
handle: PageImageHandle;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
* What a
|
|
38
|
+
* What a tile plane paints right now. `paint` draws ONLY from resolved
|
|
39
39
|
* rasters — retained generations live here until the release rules fire;
|
|
40
40
|
* "loading" never reaches the DOM. `fetching` is diagnostic (badge/tests).
|
|
41
41
|
*/
|
|
@@ -48,19 +48,58 @@ interface TilePaintPlan {
|
|
|
48
48
|
/** Memoization stamp — a new object appears only when this changes. */
|
|
49
49
|
stamp: string;
|
|
50
50
|
}
|
|
51
|
-
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
/**
|
|
52
|
+
* The base-plane strategy: the pixel BUDGET and the render points below it.
|
|
53
|
+
* Device px throughout (CSS px × devicePixelRatio).
|
|
54
|
+
*/
|
|
55
|
+
interface FullPageOptions {
|
|
56
|
+
/**
|
|
57
|
+
* The budget: no full-page raster ever renders wider. Small by design —
|
|
58
|
+
* the base is the instant backdrop; sharpness past it is the tile plane's
|
|
59
|
+
* job. Default 640.
|
|
60
|
+
*/
|
|
61
|
+
maxWidth?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Render points under a `continuous` policy. `'exact'` (default) renders
|
|
64
|
+
* the settled demand precisely — resting pixels are never resampled, the
|
|
65
|
+
* only way ~1px text stems stay crisp on dpr-1 screens. A width ladder
|
|
66
|
+
* opts into rung caching instead (defensible on dpr≥2 embeds). An
|
|
67
|
+
* advertised deployment lattice always wins over either.
|
|
68
|
+
*/
|
|
69
|
+
quantize?: 'exact' | readonly number[];
|
|
70
|
+
}
|
|
71
|
+
/** The tile-plane strategy. Pass `tiles: false` to disable the plane. */
|
|
72
|
+
interface TilesOptions {
|
|
73
|
+
/** Tile edge in device px. Default 512 (policy `tileSizes` win when advertised). */
|
|
74
|
+
size?: number;
|
|
75
|
+
/**
|
|
76
|
+
* Tile levels under a `continuous` policy: `'exact'` (default) renders the
|
|
77
|
+
* settled scale precisely; a scale ladder opts into pyramid reuse. An
|
|
78
|
+
* advertised `policy.tiles` block always wins.
|
|
79
|
+
*/
|
|
80
|
+
quantize?: 'exact' | readonly number[];
|
|
81
|
+
/**
|
|
82
|
+
* Exact-mode safety clamp on the tile level (device px per point) — the
|
|
83
|
+
* sharpness ceiling. Past `maxScale × pageWidth` device px of demand,
|
|
84
|
+
* tiles CSS-stretch instead of re-rendering. Per-screen tile cost is
|
|
85
|
+
* constant at any level, so this bounds nothing but numeric range.
|
|
86
|
+
* Default 128 (≈ 6,400% zoom on a letter page at dpr 2).
|
|
87
|
+
*/
|
|
88
|
+
maxScale?: number;
|
|
55
89
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
90
|
+
* Overlap neighboring tiles by this many device pixels per shared edge
|
|
91
|
+
* (each tile renders a slightly larger region and is placed to match).
|
|
92
|
+
* Kills hairline seams whenever tiles display at anything other than 1:1 —
|
|
93
|
+
* separate `<img>`s at fractional boundaries each get partial-coverage
|
|
94
|
+
* edge anti-aliasing, and bilinear scaling smears their last row — by
|
|
95
|
+
* making every edge land over the neighbor's identical content instead of
|
|
96
|
+
* the backdrop. Default 1; 0 disables.
|
|
58
97
|
*/
|
|
59
|
-
|
|
98
|
+
bleed?: number;
|
|
60
99
|
/**
|
|
61
|
-
* Sharpness deficit (desired ÷ supplied-by-base) above which tiles
|
|
62
|
-
*
|
|
63
|
-
*
|
|
100
|
+
* Sharpness deficit (desired ÷ supplied-by-base) above which tiles engage.
|
|
101
|
+
* Resolved default: 1.0 when the base is exact (nothing may rest
|
|
102
|
+
* stretched), 1.25 under a lattice.
|
|
64
103
|
*/
|
|
65
104
|
engageAt?: number;
|
|
66
105
|
/** Prefetch ring around the visible rect. */
|
|
@@ -71,19 +110,53 @@ interface TilingConfig {
|
|
|
71
110
|
velocityBias?: boolean;
|
|
72
111
|
};
|
|
73
112
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
113
|
+
* Settle gate for LEVEL changes (a zoom in motion): tile fetches for a new
|
|
114
|
+
* level wait this long; pan-driven fetches at the current level fire
|
|
115
|
+
* immediately. Default 150ms; 0 disables.
|
|
77
116
|
*/
|
|
78
117
|
settleMs?: number;
|
|
118
|
+
/** Optional arrival cross-fade for tiles, in ms. Default 0 (hard pop —
|
|
119
|
+
* clean once painting is decode-gated). */
|
|
120
|
+
fadeMs?: number;
|
|
79
121
|
}
|
|
80
122
|
//#endregion
|
|
81
123
|
//#region src/types.d.ts
|
|
82
|
-
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
124
|
+
/**
|
|
125
|
+
* Options for `renderPlugin()` — the render STRATEGY: what the viewer
|
|
126
|
+
* chooses to spend, and which render points it uses when the engine permits
|
|
127
|
+
* anything. The shape mirrors the deployment policy (`policy.fullPage` /
|
|
128
|
+
* `policy.tiles`), and the one composition rule is: a strategy value
|
|
129
|
+
* applies as written under a `continuous` policy, and the advertised
|
|
130
|
+
* lattice wins when there is one — so the same options run unchanged
|
|
131
|
+
* against local and cloud.
|
|
132
|
+
*/
|
|
85
133
|
interface RenderPluginOptions {
|
|
86
|
-
|
|
134
|
+
/** Base plane: the pixel budget + render points. */
|
|
135
|
+
fullPage?: FullPageOptions;
|
|
136
|
+
/** Tile plane strategy; `false` disables the plane entirely. */
|
|
137
|
+
tiles?: TilesOptions | false;
|
|
138
|
+
/**
|
|
139
|
+
* Encode format for BOTH planes. Unset → engine default (png local, the
|
|
140
|
+
* deployment's format on cloud). `'bmp'` is the local fast path — no
|
|
141
|
+
* compression, no encoder-worker round trip; under a lattice it conforms
|
|
142
|
+
* to `policy.formats`.
|
|
143
|
+
*/
|
|
144
|
+
format?: NonNullable<PageImageOptions['format']>;
|
|
145
|
+
/** Encoder quality (webp/png); ignored for bmp. */
|
|
146
|
+
quality?: number;
|
|
147
|
+
/**
|
|
148
|
+
* Diagnostic logging: tile scheduling, settle timing, fetch outcomes —
|
|
149
|
+
* the counters that catch convergence issues in long sessions. Console
|
|
150
|
+
* `debug` level; off by default.
|
|
151
|
+
*/
|
|
152
|
+
debug?: boolean;
|
|
153
|
+
}
|
|
154
|
+
/** Layer-facing paint settings (resolved options the view layers need). */
|
|
155
|
+
interface PaintSettings {
|
|
156
|
+
/** Tile arrival cross-fade (ms); 0 = hard pop. */
|
|
157
|
+
fadeMs: number;
|
|
158
|
+
/** Whether the tile plane is enabled at all (`tiles: false` opts out). */
|
|
159
|
+
tiles: boolean;
|
|
87
160
|
}
|
|
88
161
|
interface RenderPageOptions {
|
|
89
162
|
/** Device px per PDF point (use the page transform's `renderScale`). */
|
|
@@ -136,26 +209,75 @@ type RenderAction = {
|
|
|
136
209
|
type: 'PAINT_ADVANCED';
|
|
137
210
|
pon: PageObjectNumber;
|
|
138
211
|
};
|
|
212
|
+
/**
|
|
213
|
+
* One view's scoped tile surface (see {@link RenderCapability.tilesFor}).
|
|
214
|
+
* Identity (the view) is bound at creation; every call addresses that view's
|
|
215
|
+
* own state for the given page.
|
|
216
|
+
*/
|
|
217
|
+
interface ViewTiles {
|
|
218
|
+
/**
|
|
219
|
+
* The tile paint plan for a page under this view's demand. Tiling is a
|
|
220
|
+
* STRATEGY inside this plugin, not a sibling.
|
|
221
|
+
* Memoized: the same object returns until the demand, an epoch, or a
|
|
222
|
+
* tile resolution actually changes it, so layers can subscribe with
|
|
223
|
+
* plain `Object.is`. Calling it schedules the want-set fetches (visible
|
|
224
|
+
* first, center-out, prefetch ring after) — idempotent, store-deduped.
|
|
225
|
+
* Engagement is pure arithmetic against what the base will ACTUALLY
|
|
226
|
+
* supply (the same `baseAsk` the base layer sizes with): tiles fire when
|
|
227
|
+
* demand exceeds the budget/ladder cap × engageAt — on every engine.
|
|
228
|
+
* A thumbnail-sized demand never engages.
|
|
229
|
+
*/
|
|
230
|
+
plan(pon: PageObjectNumber, demand: PageViewDemand, opts?: {
|
|
231
|
+
includeAnnotations?: boolean;
|
|
232
|
+
}): TilePaintPlan;
|
|
233
|
+
/**
|
|
234
|
+
* The painter's report: the image for this plan key had a presentation
|
|
235
|
+
* opportunity. Retained coarser generations covered by painted want-set
|
|
236
|
+
* tiles release on this signal — never on fetch completion or image load,
|
|
237
|
+
* which could drop the backdrop before replacement pixels are presented.
|
|
238
|
+
*/
|
|
239
|
+
painted(pon: PageObjectNumber, key: string): void;
|
|
240
|
+
/**
|
|
241
|
+
* The inverse report: this plan key's <img> left the DOM, so its pixels
|
|
242
|
+
* are no longer compositable. Painted is a statement about the SCREEN and
|
|
243
|
+
* must follow the DOM — a remounting tile re-decodes, and until it
|
|
244
|
+
* reports painted again, retention may not count it as coverage.
|
|
245
|
+
*/
|
|
246
|
+
unpainted(pon: PageObjectNumber, key: string): void;
|
|
247
|
+
/** This view unmounted its tile plane for the page: abort in-flight tile
|
|
248
|
+
* fetches, drop ITS bookkeeping (resolved bytes stay cached). */
|
|
249
|
+
release(pon: PageObjectNumber): void;
|
|
250
|
+
}
|
|
139
251
|
interface RenderCapability {
|
|
252
|
+
/**
|
|
253
|
+
* The twin (permissions.md): would page rasters be served to this session?
|
|
254
|
+
* Mirrors `doc.render`. When false, `renderPage` and the tile plane refuse
|
|
255
|
+
* locally (no doomed engine round-trips — the gate case for a capability
|
|
256
|
+
* whose denial would otherwise 403 on every viewport tile) and a host can
|
|
257
|
+
* render its "no preview" state instead of error tiles.
|
|
258
|
+
*/
|
|
259
|
+
canRender(): boolean;
|
|
140
260
|
/**
|
|
141
261
|
* Render a page (by its durable pon) to an ENCODED image. Abortable. Encoded
|
|
142
262
|
* output is identical for local & cloud and cheap over the wire (vs. raw RGBA).
|
|
143
263
|
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
* LRU)
|
|
264
|
+
* This is the VIEWER door: the desired `scale` conforms through the
|
|
265
|
+
* resolved render points (STRATEGY ∧ POLICY) — the exact demand capped at
|
|
266
|
+
* the pixel budget under `continuous`, the advertised ladder under a
|
|
267
|
+
* lattice — and same-key requests collapse in the plugin's raster store
|
|
268
|
+
* (singleflight + LRU). Scale-precise offline output (export, print)
|
|
269
|
+
* belongs on the engine door: `doc.page(pon).render.image(...)`.
|
|
149
270
|
*/
|
|
150
271
|
renderPage(pon: PageObjectNumber, options: RenderPageOptions): Promise<PageImageHandle>;
|
|
151
272
|
/**
|
|
152
273
|
* The identity of the raster `renderPage` would produce for these options —
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
274
|
+
* conformed width + annotations flag + epoch, as one stable string. Layers
|
|
275
|
+
* key their fetch effect on THIS instead of the raw scale. Under a lattice
|
|
276
|
+
* it moves only at rung crossings; under exact-mode `continuous` it tracks
|
|
277
|
+
* the demand, is constant above the budget (always the budget width), and
|
|
278
|
+
* the LAYER settle-gates adoption so it never refetches mid-gesture.
|
|
279
|
+
* Always available: the kernel materializes the policy on `DocumentMeta`
|
|
280
|
+
* before the document publishes.
|
|
159
281
|
*/
|
|
160
282
|
renderSourceKey(pon: PageObjectNumber, options: {
|
|
161
283
|
scale: number;
|
|
@@ -163,34 +285,25 @@ interface RenderCapability {
|
|
|
163
285
|
}): string;
|
|
164
286
|
/**
|
|
165
287
|
* The canonical viewport a desired scale conforms to for this page —
|
|
166
|
-
* width-kind
|
|
288
|
+
* always width-kind: the exact demand capped at the budget (exact mode)
|
|
289
|
+
* or the snapped rung (ladder/lattice mode).
|
|
167
290
|
*/
|
|
168
291
|
conformViewport(pon: PageObjectNumber, scale: number): PageRenderViewport;
|
|
292
|
+
/** Resolved layer-facing paint settings (settle, fade, tiles on/off). */
|
|
293
|
+
paintSettings(): PaintSettings;
|
|
169
294
|
/** The document's advertised policy (sugar over `DocumentMeta.renderPolicy`). */
|
|
170
295
|
renderPolicy(): EngineRenderPolicy;
|
|
171
296
|
/**
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
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.
|
|
297
|
+
* This view's tile surface — the ONE tile entry point. `view` is the
|
|
298
|
+
* consuming view's identity (`PageContextValue.view`: a stage lens id, or
|
|
299
|
+
* a PageView instance id). Tile state is kept PER VIEW × PAGE, so two
|
|
300
|
+
* views showing the same page plan independently — a thumbnail rail's
|
|
301
|
+
* never-engaging demand cannot disturb the main view's tiles. Binding the
|
|
302
|
+
* identity ONCE makes it unforgettable and unmixable: the handle's four
|
|
303
|
+
* calls can never disagree about whose state they address. Stable per
|
|
304
|
+
* view — safe as a hook/effect dependency.
|
|
189
305
|
*/
|
|
190
|
-
|
|
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;
|
|
306
|
+
tilesFor(view: string): ViewTiles;
|
|
194
307
|
/**
|
|
195
308
|
* Version of the raster the given options would produce. Key a long-lived
|
|
196
309
|
* render on it: when it bumps, refetch. Base renders version on content
|
|
@@ -229,5 +342,5 @@ declare const RenderToken: import("@embedpdf/core").CapabilityToken<RenderCapabi
|
|
|
229
342
|
*/
|
|
230
343
|
declare const renderPlugin: (options?: RenderPluginOptions) => import("@embedpdf/core").PluginDef<RenderState, RenderAction, RenderCapability>;
|
|
231
344
|
//#endregion
|
|
232
|
-
export { type InvalidateScope, type PageViewDemand, type RenderCapability, type RenderPluginOptions, type RenderState, RenderToken, type TilePaintPlan, type TilePaintSource, type
|
|
345
|
+
export { type FullPageOptions, type InvalidateScope, type PageViewDemand, type PaintSettings, type RenderCapability, type RenderPluginOptions, type RenderState, RenderToken, type TilePaintPlan, type TilePaintSource, type TilesOptions, renderPlugin };
|
|
233
346
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EngineRenderPolicy, PageImageHandle, PageObjectNumber, PageRenderViewport } from "@embedpdf/core";
|
|
1
|
+
import { EngineRenderPolicy, PageImageHandle, PageImageOptions, PageObjectNumber, PageRenderViewport } from "@embedpdf/core";
|
|
2
2
|
import { Rect } from "@embedpdf/core-geometry";
|
|
3
3
|
//#region src/paint-plan.d.ts
|
|
4
4
|
/**
|
|
@@ -35,7 +35,7 @@ interface TilePaintSource {
|
|
|
35
35
|
handle: PageImageHandle;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
* What a
|
|
38
|
+
* What a tile plane paints right now. `paint` draws ONLY from resolved
|
|
39
39
|
* rasters — retained generations live here until the release rules fire;
|
|
40
40
|
* "loading" never reaches the DOM. `fetching` is diagnostic (badge/tests).
|
|
41
41
|
*/
|
|
@@ -48,19 +48,58 @@ interface TilePaintPlan {
|
|
|
48
48
|
/** Memoization stamp — a new object appears only when this changes. */
|
|
49
49
|
stamp: string;
|
|
50
50
|
}
|
|
51
|
-
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
/**
|
|
52
|
+
* The base-plane strategy: the pixel BUDGET and the render points below it.
|
|
53
|
+
* Device px throughout (CSS px × devicePixelRatio).
|
|
54
|
+
*/
|
|
55
|
+
interface FullPageOptions {
|
|
56
|
+
/**
|
|
57
|
+
* The budget: no full-page raster ever renders wider. Small by design —
|
|
58
|
+
* the base is the instant backdrop; sharpness past it is the tile plane's
|
|
59
|
+
* job. Default 640.
|
|
60
|
+
*/
|
|
61
|
+
maxWidth?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Render points under a `continuous` policy. `'exact'` (default) renders
|
|
64
|
+
* the settled demand precisely — resting pixels are never resampled, the
|
|
65
|
+
* only way ~1px text stems stay crisp on dpr-1 screens. A width ladder
|
|
66
|
+
* opts into rung caching instead (defensible on dpr≥2 embeds). An
|
|
67
|
+
* advertised deployment lattice always wins over either.
|
|
68
|
+
*/
|
|
69
|
+
quantize?: 'exact' | readonly number[];
|
|
70
|
+
}
|
|
71
|
+
/** The tile-plane strategy. Pass `tiles: false` to disable the plane. */
|
|
72
|
+
interface TilesOptions {
|
|
73
|
+
/** Tile edge in device px. Default 512 (policy `tileSizes` win when advertised). */
|
|
74
|
+
size?: number;
|
|
75
|
+
/**
|
|
76
|
+
* Tile levels under a `continuous` policy: `'exact'` (default) renders the
|
|
77
|
+
* settled scale precisely; a scale ladder opts into pyramid reuse. An
|
|
78
|
+
* advertised `policy.tiles` block always wins.
|
|
79
|
+
*/
|
|
80
|
+
quantize?: 'exact' | readonly number[];
|
|
81
|
+
/**
|
|
82
|
+
* Exact-mode safety clamp on the tile level (device px per point) — the
|
|
83
|
+
* sharpness ceiling. Past `maxScale × pageWidth` device px of demand,
|
|
84
|
+
* tiles CSS-stretch instead of re-rendering. Per-screen tile cost is
|
|
85
|
+
* constant at any level, so this bounds nothing but numeric range.
|
|
86
|
+
* Default 128 (≈ 6,400% zoom on a letter page at dpr 2).
|
|
87
|
+
*/
|
|
88
|
+
maxScale?: number;
|
|
55
89
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
90
|
+
* Overlap neighboring tiles by this many device pixels per shared edge
|
|
91
|
+
* (each tile renders a slightly larger region and is placed to match).
|
|
92
|
+
* Kills hairline seams whenever tiles display at anything other than 1:1 —
|
|
93
|
+
* separate `<img>`s at fractional boundaries each get partial-coverage
|
|
94
|
+
* edge anti-aliasing, and bilinear scaling smears their last row — by
|
|
95
|
+
* making every edge land over the neighbor's identical content instead of
|
|
96
|
+
* the backdrop. Default 1; 0 disables.
|
|
58
97
|
*/
|
|
59
|
-
|
|
98
|
+
bleed?: number;
|
|
60
99
|
/**
|
|
61
|
-
* Sharpness deficit (desired ÷ supplied-by-base) above which tiles
|
|
62
|
-
*
|
|
63
|
-
*
|
|
100
|
+
* Sharpness deficit (desired ÷ supplied-by-base) above which tiles engage.
|
|
101
|
+
* Resolved default: 1.0 when the base is exact (nothing may rest
|
|
102
|
+
* stretched), 1.25 under a lattice.
|
|
64
103
|
*/
|
|
65
104
|
engageAt?: number;
|
|
66
105
|
/** Prefetch ring around the visible rect. */
|
|
@@ -71,19 +110,53 @@ interface TilingConfig {
|
|
|
71
110
|
velocityBias?: boolean;
|
|
72
111
|
};
|
|
73
112
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
113
|
+
* Settle gate for LEVEL changes (a zoom in motion): tile fetches for a new
|
|
114
|
+
* level wait this long; pan-driven fetches at the current level fire
|
|
115
|
+
* immediately. Default 150ms; 0 disables.
|
|
77
116
|
*/
|
|
78
117
|
settleMs?: number;
|
|
118
|
+
/** Optional arrival cross-fade for tiles, in ms. Default 0 (hard pop —
|
|
119
|
+
* clean once painting is decode-gated). */
|
|
120
|
+
fadeMs?: number;
|
|
79
121
|
}
|
|
80
122
|
//#endregion
|
|
81
123
|
//#region src/types.d.ts
|
|
82
|
-
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
124
|
+
/**
|
|
125
|
+
* Options for `renderPlugin()` — the render STRATEGY: what the viewer
|
|
126
|
+
* chooses to spend, and which render points it uses when the engine permits
|
|
127
|
+
* anything. The shape mirrors the deployment policy (`policy.fullPage` /
|
|
128
|
+
* `policy.tiles`), and the one composition rule is: a strategy value
|
|
129
|
+
* applies as written under a `continuous` policy, and the advertised
|
|
130
|
+
* lattice wins when there is one — so the same options run unchanged
|
|
131
|
+
* against local and cloud.
|
|
132
|
+
*/
|
|
85
133
|
interface RenderPluginOptions {
|
|
86
|
-
|
|
134
|
+
/** Base plane: the pixel budget + render points. */
|
|
135
|
+
fullPage?: FullPageOptions;
|
|
136
|
+
/** Tile plane strategy; `false` disables the plane entirely. */
|
|
137
|
+
tiles?: TilesOptions | false;
|
|
138
|
+
/**
|
|
139
|
+
* Encode format for BOTH planes. Unset → engine default (png local, the
|
|
140
|
+
* deployment's format on cloud). `'bmp'` is the local fast path — no
|
|
141
|
+
* compression, no encoder-worker round trip; under a lattice it conforms
|
|
142
|
+
* to `policy.formats`.
|
|
143
|
+
*/
|
|
144
|
+
format?: NonNullable<PageImageOptions['format']>;
|
|
145
|
+
/** Encoder quality (webp/png); ignored for bmp. */
|
|
146
|
+
quality?: number;
|
|
147
|
+
/**
|
|
148
|
+
* Diagnostic logging: tile scheduling, settle timing, fetch outcomes —
|
|
149
|
+
* the counters that catch convergence issues in long sessions. Console
|
|
150
|
+
* `debug` level; off by default.
|
|
151
|
+
*/
|
|
152
|
+
debug?: boolean;
|
|
153
|
+
}
|
|
154
|
+
/** Layer-facing paint settings (resolved options the view layers need). */
|
|
155
|
+
interface PaintSettings {
|
|
156
|
+
/** Tile arrival cross-fade (ms); 0 = hard pop. */
|
|
157
|
+
fadeMs: number;
|
|
158
|
+
/** Whether the tile plane is enabled at all (`tiles: false` opts out). */
|
|
159
|
+
tiles: boolean;
|
|
87
160
|
}
|
|
88
161
|
interface RenderPageOptions {
|
|
89
162
|
/** Device px per PDF point (use the page transform's `renderScale`). */
|
|
@@ -136,26 +209,75 @@ type RenderAction = {
|
|
|
136
209
|
type: 'PAINT_ADVANCED';
|
|
137
210
|
pon: PageObjectNumber;
|
|
138
211
|
};
|
|
212
|
+
/**
|
|
213
|
+
* One view's scoped tile surface (see {@link RenderCapability.tilesFor}).
|
|
214
|
+
* Identity (the view) is bound at creation; every call addresses that view's
|
|
215
|
+
* own state for the given page.
|
|
216
|
+
*/
|
|
217
|
+
interface ViewTiles {
|
|
218
|
+
/**
|
|
219
|
+
* The tile paint plan for a page under this view's demand. Tiling is a
|
|
220
|
+
* STRATEGY inside this plugin, not a sibling.
|
|
221
|
+
* Memoized: the same object returns until the demand, an epoch, or a
|
|
222
|
+
* tile resolution actually changes it, so layers can subscribe with
|
|
223
|
+
* plain `Object.is`. Calling it schedules the want-set fetches (visible
|
|
224
|
+
* first, center-out, prefetch ring after) — idempotent, store-deduped.
|
|
225
|
+
* Engagement is pure arithmetic against what the base will ACTUALLY
|
|
226
|
+
* supply (the same `baseAsk` the base layer sizes with): tiles fire when
|
|
227
|
+
* demand exceeds the budget/ladder cap × engageAt — on every engine.
|
|
228
|
+
* A thumbnail-sized demand never engages.
|
|
229
|
+
*/
|
|
230
|
+
plan(pon: PageObjectNumber, demand: PageViewDemand, opts?: {
|
|
231
|
+
includeAnnotations?: boolean;
|
|
232
|
+
}): TilePaintPlan;
|
|
233
|
+
/**
|
|
234
|
+
* The painter's report: the image for this plan key had a presentation
|
|
235
|
+
* opportunity. Retained coarser generations covered by painted want-set
|
|
236
|
+
* tiles release on this signal — never on fetch completion or image load,
|
|
237
|
+
* which could drop the backdrop before replacement pixels are presented.
|
|
238
|
+
*/
|
|
239
|
+
painted(pon: PageObjectNumber, key: string): void;
|
|
240
|
+
/**
|
|
241
|
+
* The inverse report: this plan key's <img> left the DOM, so its pixels
|
|
242
|
+
* are no longer compositable. Painted is a statement about the SCREEN and
|
|
243
|
+
* must follow the DOM — a remounting tile re-decodes, and until it
|
|
244
|
+
* reports painted again, retention may not count it as coverage.
|
|
245
|
+
*/
|
|
246
|
+
unpainted(pon: PageObjectNumber, key: string): void;
|
|
247
|
+
/** This view unmounted its tile plane for the page: abort in-flight tile
|
|
248
|
+
* fetches, drop ITS bookkeeping (resolved bytes stay cached). */
|
|
249
|
+
release(pon: PageObjectNumber): void;
|
|
250
|
+
}
|
|
139
251
|
interface RenderCapability {
|
|
252
|
+
/**
|
|
253
|
+
* The twin (permissions.md): would page rasters be served to this session?
|
|
254
|
+
* Mirrors `doc.render`. When false, `renderPage` and the tile plane refuse
|
|
255
|
+
* locally (no doomed engine round-trips — the gate case for a capability
|
|
256
|
+
* whose denial would otherwise 403 on every viewport tile) and a host can
|
|
257
|
+
* render its "no preview" state instead of error tiles.
|
|
258
|
+
*/
|
|
259
|
+
canRender(): boolean;
|
|
140
260
|
/**
|
|
141
261
|
* Render a page (by its durable pon) to an ENCODED image. Abortable. Encoded
|
|
142
262
|
* output is identical for local & cloud and cheap over the wire (vs. raw RGBA).
|
|
143
263
|
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
* LRU)
|
|
264
|
+
* This is the VIEWER door: the desired `scale` conforms through the
|
|
265
|
+
* resolved render points (STRATEGY ∧ POLICY) — the exact demand capped at
|
|
266
|
+
* the pixel budget under `continuous`, the advertised ladder under a
|
|
267
|
+
* lattice — and same-key requests collapse in the plugin's raster store
|
|
268
|
+
* (singleflight + LRU). Scale-precise offline output (export, print)
|
|
269
|
+
* belongs on the engine door: `doc.page(pon).render.image(...)`.
|
|
149
270
|
*/
|
|
150
271
|
renderPage(pon: PageObjectNumber, options: RenderPageOptions): Promise<PageImageHandle>;
|
|
151
272
|
/**
|
|
152
273
|
* The identity of the raster `renderPage` would produce for these options —
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
274
|
+
* conformed width + annotations flag + epoch, as one stable string. Layers
|
|
275
|
+
* key their fetch effect on THIS instead of the raw scale. Under a lattice
|
|
276
|
+
* it moves only at rung crossings; under exact-mode `continuous` it tracks
|
|
277
|
+
* the demand, is constant above the budget (always the budget width), and
|
|
278
|
+
* the LAYER settle-gates adoption so it never refetches mid-gesture.
|
|
279
|
+
* Always available: the kernel materializes the policy on `DocumentMeta`
|
|
280
|
+
* before the document publishes.
|
|
159
281
|
*/
|
|
160
282
|
renderSourceKey(pon: PageObjectNumber, options: {
|
|
161
283
|
scale: number;
|
|
@@ -163,34 +285,25 @@ interface RenderCapability {
|
|
|
163
285
|
}): string;
|
|
164
286
|
/**
|
|
165
287
|
* The canonical viewport a desired scale conforms to for this page —
|
|
166
|
-
* width-kind
|
|
288
|
+
* always width-kind: the exact demand capped at the budget (exact mode)
|
|
289
|
+
* or the snapped rung (ladder/lattice mode).
|
|
167
290
|
*/
|
|
168
291
|
conformViewport(pon: PageObjectNumber, scale: number): PageRenderViewport;
|
|
292
|
+
/** Resolved layer-facing paint settings (settle, fade, tiles on/off). */
|
|
293
|
+
paintSettings(): PaintSettings;
|
|
169
294
|
/** The document's advertised policy (sugar over `DocumentMeta.renderPolicy`). */
|
|
170
295
|
renderPolicy(): EngineRenderPolicy;
|
|
171
296
|
/**
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
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.
|
|
297
|
+
* This view's tile surface — the ONE tile entry point. `view` is the
|
|
298
|
+
* consuming view's identity (`PageContextValue.view`: a stage lens id, or
|
|
299
|
+
* a PageView instance id). Tile state is kept PER VIEW × PAGE, so two
|
|
300
|
+
* views showing the same page plan independently — a thumbnail rail's
|
|
301
|
+
* never-engaging demand cannot disturb the main view's tiles. Binding the
|
|
302
|
+
* identity ONCE makes it unforgettable and unmixable: the handle's four
|
|
303
|
+
* calls can never disagree about whose state they address. Stable per
|
|
304
|
+
* view — safe as a hook/effect dependency.
|
|
189
305
|
*/
|
|
190
|
-
|
|
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;
|
|
306
|
+
tilesFor(view: string): ViewTiles;
|
|
194
307
|
/**
|
|
195
308
|
* Version of the raster the given options would produce. Key a long-lived
|
|
196
309
|
* render on it: when it bumps, refetch. Base renders version on content
|
|
@@ -229,5 +342,5 @@ declare const RenderToken: import("@embedpdf/core").CapabilityToken<RenderCapabi
|
|
|
229
342
|
*/
|
|
230
343
|
declare const renderPlugin: (options?: RenderPluginOptions) => import("@embedpdf/core").PluginDef<RenderState, RenderAction, RenderCapability>;
|
|
231
344
|
//#endregion
|
|
232
|
-
export { type InvalidateScope, type PageViewDemand, type RenderCapability, type RenderPluginOptions, type RenderState, RenderToken, type TilePaintPlan, type TilePaintSource, type
|
|
345
|
+
export { type FullPageOptions, type InvalidateScope, type PageViewDemand, type PaintSettings, type RenderCapability, type RenderPluginOptions, type RenderState, RenderToken, type TilePaintPlan, type TilePaintSource, type TilesOptions, renderPlugin };
|
|
233
346
|
//# sourceMappingURL=index.d.ts.map
|