@embedpdf/plugin-render 3.0.0-next.14 → 3.0.0-next.16
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/contract/host.cjs +18 -0
- package/dist/contract/host.cjs.map +1 -0
- package/dist/contract/host.d.cts +3 -0
- package/dist/contract/host.d.ts +3 -0
- package/dist/contract/host.js +16 -0
- package/dist/contract/host.js.map +1 -0
- package/dist/contract-CGcu-84H.cjs +124 -0
- package/dist/contract-CGcu-84H.cjs.map +1 -0
- package/dist/contract-Dy5TiQDy.js +95 -0
- package/dist/contract-Dy5TiQDy.js.map +1 -0
- package/dist/contract-uc5nOice.d.cts +279 -0
- package/dist/contract-uc5nOice.d.ts +279 -0
- package/dist/contract.cjs +3 -1
- package/dist/contract.d.cts +2 -2
- package/dist/contract.d.ts +2 -2
- package/dist/contract.js +2 -2
- package/dist/host-contract-CTOQn0Xz.d.cts +127 -0
- package/dist/host-contract-CsjZjWjb.d.ts +127 -0
- package/dist/index.cjs +869 -493
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -12
- package/dist/index.d.ts +29 -12
- package/dist/index.js +866 -492
- package/dist/index.js.map +1 -1
- package/package.json +7 -3
- package/dist/contract-Bvlo2Ukp.cjs +0 -11
- package/dist/contract-Bvlo2Ukp.cjs.map +0 -1
- package/dist/contract-BvwW7rrm.js +0 -7
- package/dist/contract-BvwW7rrm.js.map +0 -1
- package/dist/contract-CWPMd1OW.d.cts +0 -332
- package/dist/contract-CWPMd1OW.d.ts +0 -332
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { BatchResult, DeepPartial, EngineRenderPolicy, EventHook, EventOrigin, OperationOptions, PageImageHandle, PageImageOptions, PageRef, SettingsApi } 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 means the 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
|
+
* Whether two demands ask for the same thing. A host builds a new demand object on every camera
|
|
25
|
+
* frame; a layer that compares with this sets it again (and plans again) only when it changed.
|
|
26
|
+
*/
|
|
27
|
+
declare function samePageViewDemand(left: PageViewDemand, right: PageViewDemand): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* One tile the layer should have in the DOM. `key` is the reconciliation
|
|
30
|
+
* identity (stable across plan recomputes — keyed lists preserve the DOM
|
|
31
|
+
* node, which is the retention mechanism); `rect` is y-down page points
|
|
32
|
+
* inside the unrotated content box; `z` stacks by resolution so arriving
|
|
33
|
+
* sharper tiles occlude retained coarser ones per region.
|
|
34
|
+
*/
|
|
35
|
+
interface TilePaintSource {
|
|
36
|
+
key: string;
|
|
37
|
+
scale: number;
|
|
38
|
+
rect: Rect;
|
|
39
|
+
z: number;
|
|
40
|
+
handle: PageImageHandle;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* What a tile plane paints right now. `paint` draws only from resolved
|
|
44
|
+
* rasters — retained generations live here until the release rules fire;
|
|
45
|
+
* "loading" never reaches the DOM. `fetching` is diagnostic (badge/tests).
|
|
46
|
+
*/
|
|
47
|
+
interface TilePaintPlan {
|
|
48
|
+
/** Tiles engaged at all? False = the base rung fully covers demand. */
|
|
49
|
+
engaged: boolean;
|
|
50
|
+
paint: TilePaintSource[];
|
|
51
|
+
/** Keys currently in flight (want-set members not yet resolved). */
|
|
52
|
+
fetching: string[];
|
|
53
|
+
/** Memoization stamp — a new object appears only when this changes. */
|
|
54
|
+
stamp: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The base-plane strategy: the pixel budget and the render points below it.
|
|
58
|
+
* Device px throughout (CSS px × devicePixelRatio).
|
|
59
|
+
*/
|
|
60
|
+
interface FullPageOptions {
|
|
61
|
+
/**
|
|
62
|
+
* The budget: no full-page raster ever renders wider. Small by design —
|
|
63
|
+
* the base is the instant backdrop; sharpness past it is the tile plane's
|
|
64
|
+
* job. Default 640.
|
|
65
|
+
*/
|
|
66
|
+
maxWidth?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Render points under a `continuous` policy. `'exact'` (default) renders
|
|
69
|
+
* the settled demand precisely — resting pixels are never resampled, the
|
|
70
|
+
* only way ~1px text stems stay crisp on dpr-1 screens. A width ladder
|
|
71
|
+
* opts into rung caching instead (defensible on dpr≥2 embeds). An
|
|
72
|
+
* advertised deployment lattice always wins over either.
|
|
73
|
+
*/
|
|
74
|
+
quantize?: 'exact' | readonly number[];
|
|
75
|
+
}
|
|
76
|
+
/** The tile-plane strategy. Pass `tiles: false` to disable the plane. */
|
|
77
|
+
interface TilesOptions {
|
|
78
|
+
/** Tile edge in device px. Default 512 (policy `tileSizes` win when advertised). */
|
|
79
|
+
size?: number;
|
|
80
|
+
/**
|
|
81
|
+
* Tile levels under a `continuous` policy: `'exact'` (default) renders the
|
|
82
|
+
* settled scale precisely; a scale ladder opts into pyramid reuse. An
|
|
83
|
+
* advertised `policy.tiles` block always wins.
|
|
84
|
+
*/
|
|
85
|
+
quantize?: 'exact' | readonly number[];
|
|
86
|
+
/**
|
|
87
|
+
* Exact-mode safety clamp on the tile level (device px per point) — the
|
|
88
|
+
* sharpness ceiling. Past `maxScale × pageWidth` device px of demand,
|
|
89
|
+
* tiles CSS-stretch instead of re-rendering. Per-screen tile cost is
|
|
90
|
+
* constant at any level, so this bounds nothing but numeric range.
|
|
91
|
+
* Default 128 (≈ 6,400% zoom on a letter page at dpr 2).
|
|
92
|
+
*/
|
|
93
|
+
maxScale?: number;
|
|
94
|
+
/**
|
|
95
|
+
* Overlap neighboring tiles by this many device pixels per shared edge
|
|
96
|
+
* (each tile renders a slightly larger region and is placed to match).
|
|
97
|
+
* Kills hairline seams whenever tiles display at anything other than 1:1 —
|
|
98
|
+
* separate `<img>`s at fractional boundaries each get partial-coverage
|
|
99
|
+
* edge anti-aliasing, and bilinear scaling smears their last row — by
|
|
100
|
+
* making every edge land over the neighbor's identical content instead of
|
|
101
|
+
* the backdrop. Default 1; 0 disables.
|
|
102
|
+
*/
|
|
103
|
+
bleed?: number;
|
|
104
|
+
/**
|
|
105
|
+
* Sharpness deficit (desired ÷ supplied-by-base) above which tiles engage.
|
|
106
|
+
* Resolved default: 1.0 when the base is exact (nothing may rest
|
|
107
|
+
* stretched), 1.25 under a lattice.
|
|
108
|
+
*/
|
|
109
|
+
engageAt?: number;
|
|
110
|
+
/** Prefetch ring around the visible rect. */
|
|
111
|
+
prefetch?: {
|
|
112
|
+
/** Extra coverage per side, in fractions of the visible rect. Default 0.5. */
|
|
113
|
+
margin?: number;
|
|
114
|
+
/** Stretch the ring toward scroll direction. Default true. */
|
|
115
|
+
velocityBias?: boolean;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Settle gate for level changes (a zoom in motion): tile fetches for a new
|
|
119
|
+
* level wait this long; pan-driven fetches at the current level fire
|
|
120
|
+
* immediately. Default 150ms; 0 disables.
|
|
121
|
+
*/
|
|
122
|
+
settleMs?: number;
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/token.d.ts
|
|
126
|
+
declare const RenderToken: import("@embedpdf/core").CapabilityToken<RenderCapability>;
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/contract.d.ts
|
|
129
|
+
/** Encode format the engine can produce for a raster. */
|
|
130
|
+
type RenderFormat = NonNullable<PageImageOptions['format']>;
|
|
131
|
+
/**
|
|
132
|
+
* The render strategy: what the viewer chooses to spend, and which render
|
|
133
|
+
* points it uses when the engine permits anything. The shape mirrors the
|
|
134
|
+
* deployment policy (`policy.fullPage` / `policy.tiles`), and the one
|
|
135
|
+
* composition rule is: a strategy value applies as written under a
|
|
136
|
+
* `continuous` policy, and the advertised lattice wins when there is one,
|
|
137
|
+
* so the same settings run unchanged against local and cloud. They belong to
|
|
138
|
+
* the plugin as registered: `updateSettings()` changes every document.
|
|
139
|
+
*/
|
|
140
|
+
interface RenderSettings {
|
|
141
|
+
/** Base plane: the pixel budget + render points. */
|
|
142
|
+
readonly fullPage: FullPageOptions;
|
|
143
|
+
/** Tile plane strategy; `false` disables the plane entirely. */
|
|
144
|
+
readonly tiles: TilesOptions | false;
|
|
145
|
+
/**
|
|
146
|
+
* Encode format for both planes. Unset → engine default (png local, the
|
|
147
|
+
* deployment's format on cloud). `'bmp'` is the local fast path — no
|
|
148
|
+
* compression, no encoder-worker round trip; under a lattice it conforms
|
|
149
|
+
* to `policy.formats`.
|
|
150
|
+
*/
|
|
151
|
+
readonly format: RenderFormat | undefined;
|
|
152
|
+
/** WebP quality from 0 (smallest) to 1 (best); PNG and BMP ignore it. */
|
|
153
|
+
readonly quality: number | undefined;
|
|
154
|
+
/** Diagnostic logging of tile scheduling and fetch outcomes (console `debug`). */
|
|
155
|
+
readonly debug: boolean;
|
|
156
|
+
}
|
|
157
|
+
/** What the render settings are when the app registers none. */
|
|
158
|
+
declare const RENDER_DEFAULTS: RenderSettings;
|
|
159
|
+
/** What `renderPlugin(config)` takes: any of the settings, merged over the defaults. */
|
|
160
|
+
type RenderConfig = DeepPartial<RenderSettings>;
|
|
161
|
+
/**
|
|
162
|
+
* What a picture draws beside the page content. An option left out draws
|
|
163
|
+
* what the user may read: the annotations with `doc.annotate.read`, the form
|
|
164
|
+
* fields with `doc.forms.read`, and no form fields when `includeAnnotations`
|
|
165
|
+
* is `false`. `true` for something the user may not read is refused
|
|
166
|
+
* (`permission-denied`). Leave out what you paint yourself: a layer that
|
|
167
|
+
* paints annotations passes `includeAnnotations: false`, which leaves the
|
|
168
|
+
* form fields out too unless you ask for them (`includeFormFields: true`).
|
|
169
|
+
*/
|
|
170
|
+
interface PageLayerOptions {
|
|
171
|
+
/** Draw the annotations (form fields' widgets excepted). */
|
|
172
|
+
includeAnnotations?: boolean;
|
|
173
|
+
/** Draw the form fields, each in the state its field shows. */
|
|
174
|
+
includeFormFields?: boolean;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* An encoded page image: `source` is bytes or a URL, `format`/`contentType`
|
|
178
|
+
* say what they are, `width`/`height` its pixel size, and
|
|
179
|
+
* `objectUrl()` mints a revocable object URL for an `<img>`.
|
|
180
|
+
*/
|
|
181
|
+
type PageImage = PageImageHandle;
|
|
182
|
+
interface RenderPageOptions extends OperationOptions, PageLayerOptions {
|
|
183
|
+
/** Exact output width in device pixels (height keeps the page's aspect). */
|
|
184
|
+
width?: number;
|
|
185
|
+
/** Device pixels per PDF point; ignored when `width` is given. Default 1. */
|
|
186
|
+
scale?: number;
|
|
187
|
+
/** Per-call encode overrides; default to the plugin's strategy. */
|
|
188
|
+
format?: RenderFormat;
|
|
189
|
+
quality?: number;
|
|
190
|
+
}
|
|
191
|
+
interface RenderThumbnailOptions extends OperationOptions, PageLayerOptions {
|
|
192
|
+
/** The thumbnail's width in device pixels. */
|
|
193
|
+
maxWidth: number;
|
|
194
|
+
}
|
|
195
|
+
interface RenderPagesOptions extends RenderPageOptions {
|
|
196
|
+
/** Renders in flight at once (default 4). */
|
|
197
|
+
concurrency?: number;
|
|
198
|
+
}
|
|
199
|
+
/** One entry of a batch render. */
|
|
200
|
+
interface PageRender {
|
|
201
|
+
readonly page: PageRef;
|
|
202
|
+
readonly image: PageImage;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* The invalidation scopes — every pixel-changing fact is one of them:
|
|
206
|
+
*
|
|
207
|
+
* 'annotations' — an annotation changed. Pictures without annotations keep
|
|
208
|
+
* their pixels.
|
|
209
|
+
* 'fields' — a form field changed: a fill, a widget's place or look,
|
|
210
|
+
* a signing. Pictures without form fields keep their pixels.
|
|
211
|
+
* 'content' — the page itself changed (redaction applied, flattened).
|
|
212
|
+
* Invalidates every picture of the page.
|
|
213
|
+
*/
|
|
214
|
+
type InvalidateScope = 'content' | 'annotations' | 'fields';
|
|
215
|
+
interface InvalidateOptions {
|
|
216
|
+
/** The pages whose pixels changed, by ref or index; omitted = every page. */
|
|
217
|
+
pages?: readonly (PageRef | number)[];
|
|
218
|
+
/** Defaults to `'content'` — a caller who doesn't say is safest repainted fully. */
|
|
219
|
+
scope?: InvalidateScope;
|
|
220
|
+
}
|
|
221
|
+
/** Pixels changed on these pages: a confirmed document mutation (own or
|
|
222
|
+
* remote) or an `invalidate` call. Anything holding a rendered bitmap refetches. */
|
|
223
|
+
interface RenderInvalidatedEvent {
|
|
224
|
+
readonly pages: readonly PageRef[];
|
|
225
|
+
readonly scope: InvalidateScope;
|
|
226
|
+
/**
|
|
227
|
+
* Where the document mutation came from. Null when a caller requested the
|
|
228
|
+
* invalidation through {@link RenderCapability.invalidate}.
|
|
229
|
+
*/
|
|
230
|
+
readonly origin: EventOrigin | null;
|
|
231
|
+
}
|
|
232
|
+
interface RenderCapability extends SettingsApi<RenderSettings> {
|
|
233
|
+
/**
|
|
234
|
+
* Would page rasters be served to this session (`doc.render`)? When false
|
|
235
|
+
* every render refuses locally with `permission-denied` — no doomed engine
|
|
236
|
+
* round-trips — and a host can show its "no preview" state instead.
|
|
237
|
+
*/
|
|
238
|
+
canRender(): boolean;
|
|
239
|
+
/**
|
|
240
|
+
* Render one page, by its ref or its index, at the requested size. The
|
|
241
|
+
* size is honoured exactly (nothing is snapped to the viewer's render
|
|
242
|
+
* points); the shared raster cache serves the call when it already holds a
|
|
243
|
+
* matching image. Rejects `permission-denied` without `doc.render`,
|
|
244
|
+
* `not-found` for a page that is not in this document,
|
|
245
|
+
* `operation-cancelled` when `signal` fires.
|
|
246
|
+
*/
|
|
247
|
+
renderPage(page: PageRef | number, options?: RenderPageOptions): Promise<PageImage>;
|
|
248
|
+
/** Sugar for a small raster at `maxWidth` device pixels. Rejects like `renderPage`. */
|
|
249
|
+
renderThumbnail(page: PageRef | number, options: RenderThumbnailOptions): Promise<PageImage>;
|
|
250
|
+
/**
|
|
251
|
+
* Render several pages with bounded concurrency; best-effort per page: each
|
|
252
|
+
* rendered page with its image, in the order given, and each page that
|
|
253
|
+
* failed (as given) with why. Rejects `permission-denied` without
|
|
254
|
+
* `doc.render`, `operation-cancelled` when `signal` fires.
|
|
255
|
+
*/
|
|
256
|
+
renderPages(pages: readonly (PageRef | number)[], options?: RenderPagesOptions): Promise<BatchResult<PageRender, PageRef | number>>;
|
|
257
|
+
/** The deployment's advertised render policy (a document fact). */
|
|
258
|
+
getRenderPolicy(): EngineRenderPolicy;
|
|
259
|
+
/**
|
|
260
|
+
* The version of the picture the given options would produce. Key a
|
|
261
|
+
* long-lived render on it: when it bumps, refetch. A picture versions on
|
|
262
|
+
* content facts, plus annotation facts when it draws annotations and form
|
|
263
|
+
* facts when it draws form fields. Bumps only on confirmed mutations —
|
|
264
|
+
* never optimistically. 0 for a page that isn't in the document.
|
|
265
|
+
*/
|
|
266
|
+
getRenderEpoch(page: PageRef | number, layers?: PageLayerOptions): number;
|
|
267
|
+
/**
|
|
268
|
+
* Declare that page pixels changed — the open door for facts the built-in
|
|
269
|
+
* event map doesn't know (a plugin's own mutation vocabulary, anything
|
|
270
|
+
* third-party). Call at confirmation, never for optimistic previews.
|
|
271
|
+
* Fires `onInvalidated`; a page that isn't in the document is skipped.
|
|
272
|
+
*/
|
|
273
|
+
invalidate(options?: InvalidateOptions): void;
|
|
274
|
+
/** Pages' pixels changed and they will redraw. */
|
|
275
|
+
readonly onInvalidated: EventHook<RenderInvalidatedEvent>;
|
|
276
|
+
}
|
|
277
|
+
//#endregion
|
|
278
|
+
export { PageViewDemand as _, PageRender as a, TilesOptions as b, RenderConfig as c, RenderPageOptions as d, RenderPagesOptions as f, FullPageOptions as g, RenderToken as h, PageLayerOptions as i, RenderFormat as l, RenderThumbnailOptions as m, InvalidateScope as n, RENDER_DEFAULTS as o, RenderSettings as p, PageImage as r, RenderCapability as s, InvalidateOptions as t, RenderInvalidatedEvent as u, TilePaintPlan as v, samePageViewDemand as x, TilePaintSource as y };
|
|
279
|
+
//# sourceMappingURL=contract-uc5nOice.d.cts.map
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { BatchResult, DeepPartial, EngineRenderPolicy, EventHook, EventOrigin, OperationOptions, PageImageHandle, PageImageOptions, PageRef, SettingsApi } 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 means the 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
|
+
* Whether two demands ask for the same thing. A host builds a new demand object on every camera
|
|
25
|
+
* frame; a layer that compares with this sets it again (and plans again) only when it changed.
|
|
26
|
+
*/
|
|
27
|
+
declare function samePageViewDemand(left: PageViewDemand, right: PageViewDemand): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* One tile the layer should have in the DOM. `key` is the reconciliation
|
|
30
|
+
* identity (stable across plan recomputes — keyed lists preserve the DOM
|
|
31
|
+
* node, which is the retention mechanism); `rect` is y-down page points
|
|
32
|
+
* inside the unrotated content box; `z` stacks by resolution so arriving
|
|
33
|
+
* sharper tiles occlude retained coarser ones per region.
|
|
34
|
+
*/
|
|
35
|
+
interface TilePaintSource {
|
|
36
|
+
key: string;
|
|
37
|
+
scale: number;
|
|
38
|
+
rect: Rect;
|
|
39
|
+
z: number;
|
|
40
|
+
handle: PageImageHandle;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* What a tile plane paints right now. `paint` draws only from resolved
|
|
44
|
+
* rasters — retained generations live here until the release rules fire;
|
|
45
|
+
* "loading" never reaches the DOM. `fetching` is diagnostic (badge/tests).
|
|
46
|
+
*/
|
|
47
|
+
interface TilePaintPlan {
|
|
48
|
+
/** Tiles engaged at all? False = the base rung fully covers demand. */
|
|
49
|
+
engaged: boolean;
|
|
50
|
+
paint: TilePaintSource[];
|
|
51
|
+
/** Keys currently in flight (want-set members not yet resolved). */
|
|
52
|
+
fetching: string[];
|
|
53
|
+
/** Memoization stamp — a new object appears only when this changes. */
|
|
54
|
+
stamp: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The base-plane strategy: the pixel budget and the render points below it.
|
|
58
|
+
* Device px throughout (CSS px × devicePixelRatio).
|
|
59
|
+
*/
|
|
60
|
+
interface FullPageOptions {
|
|
61
|
+
/**
|
|
62
|
+
* The budget: no full-page raster ever renders wider. Small by design —
|
|
63
|
+
* the base is the instant backdrop; sharpness past it is the tile plane's
|
|
64
|
+
* job. Default 640.
|
|
65
|
+
*/
|
|
66
|
+
maxWidth?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Render points under a `continuous` policy. `'exact'` (default) renders
|
|
69
|
+
* the settled demand precisely — resting pixels are never resampled, the
|
|
70
|
+
* only way ~1px text stems stay crisp on dpr-1 screens. A width ladder
|
|
71
|
+
* opts into rung caching instead (defensible on dpr≥2 embeds). An
|
|
72
|
+
* advertised deployment lattice always wins over either.
|
|
73
|
+
*/
|
|
74
|
+
quantize?: 'exact' | readonly number[];
|
|
75
|
+
}
|
|
76
|
+
/** The tile-plane strategy. Pass `tiles: false` to disable the plane. */
|
|
77
|
+
interface TilesOptions {
|
|
78
|
+
/** Tile edge in device px. Default 512 (policy `tileSizes` win when advertised). */
|
|
79
|
+
size?: number;
|
|
80
|
+
/**
|
|
81
|
+
* Tile levels under a `continuous` policy: `'exact'` (default) renders the
|
|
82
|
+
* settled scale precisely; a scale ladder opts into pyramid reuse. An
|
|
83
|
+
* advertised `policy.tiles` block always wins.
|
|
84
|
+
*/
|
|
85
|
+
quantize?: 'exact' | readonly number[];
|
|
86
|
+
/**
|
|
87
|
+
* Exact-mode safety clamp on the tile level (device px per point) — the
|
|
88
|
+
* sharpness ceiling. Past `maxScale × pageWidth` device px of demand,
|
|
89
|
+
* tiles CSS-stretch instead of re-rendering. Per-screen tile cost is
|
|
90
|
+
* constant at any level, so this bounds nothing but numeric range.
|
|
91
|
+
* Default 128 (≈ 6,400% zoom on a letter page at dpr 2).
|
|
92
|
+
*/
|
|
93
|
+
maxScale?: number;
|
|
94
|
+
/**
|
|
95
|
+
* Overlap neighboring tiles by this many device pixels per shared edge
|
|
96
|
+
* (each tile renders a slightly larger region and is placed to match).
|
|
97
|
+
* Kills hairline seams whenever tiles display at anything other than 1:1 —
|
|
98
|
+
* separate `<img>`s at fractional boundaries each get partial-coverage
|
|
99
|
+
* edge anti-aliasing, and bilinear scaling smears their last row — by
|
|
100
|
+
* making every edge land over the neighbor's identical content instead of
|
|
101
|
+
* the backdrop. Default 1; 0 disables.
|
|
102
|
+
*/
|
|
103
|
+
bleed?: number;
|
|
104
|
+
/**
|
|
105
|
+
* Sharpness deficit (desired ÷ supplied-by-base) above which tiles engage.
|
|
106
|
+
* Resolved default: 1.0 when the base is exact (nothing may rest
|
|
107
|
+
* stretched), 1.25 under a lattice.
|
|
108
|
+
*/
|
|
109
|
+
engageAt?: number;
|
|
110
|
+
/** Prefetch ring around the visible rect. */
|
|
111
|
+
prefetch?: {
|
|
112
|
+
/** Extra coverage per side, in fractions of the visible rect. Default 0.5. */
|
|
113
|
+
margin?: number;
|
|
114
|
+
/** Stretch the ring toward scroll direction. Default true. */
|
|
115
|
+
velocityBias?: boolean;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Settle gate for level changes (a zoom in motion): tile fetches for a new
|
|
119
|
+
* level wait this long; pan-driven fetches at the current level fire
|
|
120
|
+
* immediately. Default 150ms; 0 disables.
|
|
121
|
+
*/
|
|
122
|
+
settleMs?: number;
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/token.d.ts
|
|
126
|
+
declare const RenderToken: import("@embedpdf/core").CapabilityToken<RenderCapability>;
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/contract.d.ts
|
|
129
|
+
/** Encode format the engine can produce for a raster. */
|
|
130
|
+
type RenderFormat = NonNullable<PageImageOptions['format']>;
|
|
131
|
+
/**
|
|
132
|
+
* The render strategy: what the viewer chooses to spend, and which render
|
|
133
|
+
* points it uses when the engine permits anything. The shape mirrors the
|
|
134
|
+
* deployment policy (`policy.fullPage` / `policy.tiles`), and the one
|
|
135
|
+
* composition rule is: a strategy value applies as written under a
|
|
136
|
+
* `continuous` policy, and the advertised lattice wins when there is one,
|
|
137
|
+
* so the same settings run unchanged against local and cloud. They belong to
|
|
138
|
+
* the plugin as registered: `updateSettings()` changes every document.
|
|
139
|
+
*/
|
|
140
|
+
interface RenderSettings {
|
|
141
|
+
/** Base plane: the pixel budget + render points. */
|
|
142
|
+
readonly fullPage: FullPageOptions;
|
|
143
|
+
/** Tile plane strategy; `false` disables the plane entirely. */
|
|
144
|
+
readonly tiles: TilesOptions | false;
|
|
145
|
+
/**
|
|
146
|
+
* Encode format for both planes. Unset → engine default (png local, the
|
|
147
|
+
* deployment's format on cloud). `'bmp'` is the local fast path — no
|
|
148
|
+
* compression, no encoder-worker round trip; under a lattice it conforms
|
|
149
|
+
* to `policy.formats`.
|
|
150
|
+
*/
|
|
151
|
+
readonly format: RenderFormat | undefined;
|
|
152
|
+
/** WebP quality from 0 (smallest) to 1 (best); PNG and BMP ignore it. */
|
|
153
|
+
readonly quality: number | undefined;
|
|
154
|
+
/** Diagnostic logging of tile scheduling and fetch outcomes (console `debug`). */
|
|
155
|
+
readonly debug: boolean;
|
|
156
|
+
}
|
|
157
|
+
/** What the render settings are when the app registers none. */
|
|
158
|
+
declare const RENDER_DEFAULTS: RenderSettings;
|
|
159
|
+
/** What `renderPlugin(config)` takes: any of the settings, merged over the defaults. */
|
|
160
|
+
type RenderConfig = DeepPartial<RenderSettings>;
|
|
161
|
+
/**
|
|
162
|
+
* What a picture draws beside the page content. An option left out draws
|
|
163
|
+
* what the user may read: the annotations with `doc.annotate.read`, the form
|
|
164
|
+
* fields with `doc.forms.read`, and no form fields when `includeAnnotations`
|
|
165
|
+
* is `false`. `true` for something the user may not read is refused
|
|
166
|
+
* (`permission-denied`). Leave out what you paint yourself: a layer that
|
|
167
|
+
* paints annotations passes `includeAnnotations: false`, which leaves the
|
|
168
|
+
* form fields out too unless you ask for them (`includeFormFields: true`).
|
|
169
|
+
*/
|
|
170
|
+
interface PageLayerOptions {
|
|
171
|
+
/** Draw the annotations (form fields' widgets excepted). */
|
|
172
|
+
includeAnnotations?: boolean;
|
|
173
|
+
/** Draw the form fields, each in the state its field shows. */
|
|
174
|
+
includeFormFields?: boolean;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* An encoded page image: `source` is bytes or a URL, `format`/`contentType`
|
|
178
|
+
* say what they are, `width`/`height` its pixel size, and
|
|
179
|
+
* `objectUrl()` mints a revocable object URL for an `<img>`.
|
|
180
|
+
*/
|
|
181
|
+
type PageImage = PageImageHandle;
|
|
182
|
+
interface RenderPageOptions extends OperationOptions, PageLayerOptions {
|
|
183
|
+
/** Exact output width in device pixels (height keeps the page's aspect). */
|
|
184
|
+
width?: number;
|
|
185
|
+
/** Device pixels per PDF point; ignored when `width` is given. Default 1. */
|
|
186
|
+
scale?: number;
|
|
187
|
+
/** Per-call encode overrides; default to the plugin's strategy. */
|
|
188
|
+
format?: RenderFormat;
|
|
189
|
+
quality?: number;
|
|
190
|
+
}
|
|
191
|
+
interface RenderThumbnailOptions extends OperationOptions, PageLayerOptions {
|
|
192
|
+
/** The thumbnail's width in device pixels. */
|
|
193
|
+
maxWidth: number;
|
|
194
|
+
}
|
|
195
|
+
interface RenderPagesOptions extends RenderPageOptions {
|
|
196
|
+
/** Renders in flight at once (default 4). */
|
|
197
|
+
concurrency?: number;
|
|
198
|
+
}
|
|
199
|
+
/** One entry of a batch render. */
|
|
200
|
+
interface PageRender {
|
|
201
|
+
readonly page: PageRef;
|
|
202
|
+
readonly image: PageImage;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* The invalidation scopes — every pixel-changing fact is one of them:
|
|
206
|
+
*
|
|
207
|
+
* 'annotations' — an annotation changed. Pictures without annotations keep
|
|
208
|
+
* their pixels.
|
|
209
|
+
* 'fields' — a form field changed: a fill, a widget's place or look,
|
|
210
|
+
* a signing. Pictures without form fields keep their pixels.
|
|
211
|
+
* 'content' — the page itself changed (redaction applied, flattened).
|
|
212
|
+
* Invalidates every picture of the page.
|
|
213
|
+
*/
|
|
214
|
+
type InvalidateScope = 'content' | 'annotations' | 'fields';
|
|
215
|
+
interface InvalidateOptions {
|
|
216
|
+
/** The pages whose pixels changed, by ref or index; omitted = every page. */
|
|
217
|
+
pages?: readonly (PageRef | number)[];
|
|
218
|
+
/** Defaults to `'content'` — a caller who doesn't say is safest repainted fully. */
|
|
219
|
+
scope?: InvalidateScope;
|
|
220
|
+
}
|
|
221
|
+
/** Pixels changed on these pages: a confirmed document mutation (own or
|
|
222
|
+
* remote) or an `invalidate` call. Anything holding a rendered bitmap refetches. */
|
|
223
|
+
interface RenderInvalidatedEvent {
|
|
224
|
+
readonly pages: readonly PageRef[];
|
|
225
|
+
readonly scope: InvalidateScope;
|
|
226
|
+
/**
|
|
227
|
+
* Where the document mutation came from. Null when a caller requested the
|
|
228
|
+
* invalidation through {@link RenderCapability.invalidate}.
|
|
229
|
+
*/
|
|
230
|
+
readonly origin: EventOrigin | null;
|
|
231
|
+
}
|
|
232
|
+
interface RenderCapability extends SettingsApi<RenderSettings> {
|
|
233
|
+
/**
|
|
234
|
+
* Would page rasters be served to this session (`doc.render`)? When false
|
|
235
|
+
* every render refuses locally with `permission-denied` — no doomed engine
|
|
236
|
+
* round-trips — and a host can show its "no preview" state instead.
|
|
237
|
+
*/
|
|
238
|
+
canRender(): boolean;
|
|
239
|
+
/**
|
|
240
|
+
* Render one page, by its ref or its index, at the requested size. The
|
|
241
|
+
* size is honoured exactly (nothing is snapped to the viewer's render
|
|
242
|
+
* points); the shared raster cache serves the call when it already holds a
|
|
243
|
+
* matching image. Rejects `permission-denied` without `doc.render`,
|
|
244
|
+
* `not-found` for a page that is not in this document,
|
|
245
|
+
* `operation-cancelled` when `signal` fires.
|
|
246
|
+
*/
|
|
247
|
+
renderPage(page: PageRef | number, options?: RenderPageOptions): Promise<PageImage>;
|
|
248
|
+
/** Sugar for a small raster at `maxWidth` device pixels. Rejects like `renderPage`. */
|
|
249
|
+
renderThumbnail(page: PageRef | number, options: RenderThumbnailOptions): Promise<PageImage>;
|
|
250
|
+
/**
|
|
251
|
+
* Render several pages with bounded concurrency; best-effort per page: each
|
|
252
|
+
* rendered page with its image, in the order given, and each page that
|
|
253
|
+
* failed (as given) with why. Rejects `permission-denied` without
|
|
254
|
+
* `doc.render`, `operation-cancelled` when `signal` fires.
|
|
255
|
+
*/
|
|
256
|
+
renderPages(pages: readonly (PageRef | number)[], options?: RenderPagesOptions): Promise<BatchResult<PageRender, PageRef | number>>;
|
|
257
|
+
/** The deployment's advertised render policy (a document fact). */
|
|
258
|
+
getRenderPolicy(): EngineRenderPolicy;
|
|
259
|
+
/**
|
|
260
|
+
* The version of the picture the given options would produce. Key a
|
|
261
|
+
* long-lived render on it: when it bumps, refetch. A picture versions on
|
|
262
|
+
* content facts, plus annotation facts when it draws annotations and form
|
|
263
|
+
* facts when it draws form fields. Bumps only on confirmed mutations —
|
|
264
|
+
* never optimistically. 0 for a page that isn't in the document.
|
|
265
|
+
*/
|
|
266
|
+
getRenderEpoch(page: PageRef | number, layers?: PageLayerOptions): number;
|
|
267
|
+
/**
|
|
268
|
+
* Declare that page pixels changed — the open door for facts the built-in
|
|
269
|
+
* event map doesn't know (a plugin's own mutation vocabulary, anything
|
|
270
|
+
* third-party). Call at confirmation, never for optimistic previews.
|
|
271
|
+
* Fires `onInvalidated`; a page that isn't in the document is skipped.
|
|
272
|
+
*/
|
|
273
|
+
invalidate(options?: InvalidateOptions): void;
|
|
274
|
+
/** Pages' pixels changed and they will redraw. */
|
|
275
|
+
readonly onInvalidated: EventHook<RenderInvalidatedEvent>;
|
|
276
|
+
}
|
|
277
|
+
//#endregion
|
|
278
|
+
export { PageViewDemand as _, PageRender as a, TilesOptions as b, RenderConfig as c, RenderPageOptions as d, RenderPagesOptions as f, FullPageOptions as g, RenderToken as h, PageLayerOptions as i, RenderFormat as l, RenderThumbnailOptions as m, InvalidateScope as n, RENDER_DEFAULTS as o, RenderSettings as p, PageImage as r, RenderCapability as s, InvalidateOptions as t, RenderInvalidatedEvent as u, TilePaintPlan as v, samePageViewDemand as x, TilePaintSource as y };
|
|
279
|
+
//# sourceMappingURL=contract-uc5nOice.d.ts.map
|
package/dist/contract.cjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_contract = require("./contract-
|
|
2
|
+
const require_contract = require("./contract-CGcu-84H.cjs");
|
|
3
|
+
exports.RENDER_DEFAULTS = require_contract.RENDER_DEFAULTS;
|
|
3
4
|
exports.RenderToken = require_contract.RenderToken;
|
|
5
|
+
exports.samePageViewDemand = require_contract.samePageViewDemand;
|
package/dist/contract.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { type FullPageOptions,
|
|
1
|
+
import { _ as PageViewDemand, a as PageRender, b as TilesOptions, c as RenderConfig, d as RenderPageOptions, f as RenderPagesOptions, g as FullPageOptions, h as RenderToken, i as PageLayerOptions, l as RenderFormat, m as RenderThumbnailOptions, n as InvalidateScope, o as RENDER_DEFAULTS, p as RenderSettings, r as PageImage, s as RenderCapability, t as InvalidateOptions, u as RenderInvalidatedEvent, x as samePageViewDemand } from "./contract-uc5nOice.cjs";
|
|
2
|
+
export { type FullPageOptions, InvalidateOptions, InvalidateScope, PageImage, PageLayerOptions, PageRender, type PageViewDemand, type PageViewDemand as ViewDemandInput, RENDER_DEFAULTS, RenderCapability, RenderConfig, RenderFormat, RenderInvalidatedEvent, RenderPageOptions, RenderPagesOptions, RenderSettings, RenderThumbnailOptions, RenderToken, type TilesOptions, samePageViewDemand };
|
package/dist/contract.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { type FullPageOptions,
|
|
1
|
+
import { _ as PageViewDemand, a as PageRender, b as TilesOptions, c as RenderConfig, d as RenderPageOptions, f as RenderPagesOptions, g as FullPageOptions, h as RenderToken, i as PageLayerOptions, l as RenderFormat, m as RenderThumbnailOptions, n as InvalidateScope, o as RENDER_DEFAULTS, p as RenderSettings, r as PageImage, s as RenderCapability, t as InvalidateOptions, u as RenderInvalidatedEvent, x as samePageViewDemand } from "./contract-uc5nOice.js";
|
|
2
|
+
export { type FullPageOptions, InvalidateOptions, InvalidateScope, PageImage, PageLayerOptions, PageRender, type PageViewDemand, type PageViewDemand as ViewDemandInput, RENDER_DEFAULTS, RenderCapability, RenderConfig, RenderFormat, RenderInvalidatedEvent, RenderPageOptions, RenderPagesOptions, RenderSettings, RenderThumbnailOptions, RenderToken, type TilesOptions, samePageViewDemand };
|
package/dist/contract.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { RenderToken };
|
|
1
|
+
import { a as samePageViewDemand, n as RenderToken, t as RENDER_DEFAULTS } from "./contract-Dy5TiQDy.js";
|
|
2
|
+
export { RENDER_DEFAULTS, RenderToken, samePageViewDemand };
|