@embedpdf/plugin-stage 3.0.0-next.10 → 3.0.0-next.12

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.cts CHANGED
@@ -1,646 +1,9 @@
1
- import { CapabilityToken, PageLayout, PageObjectNumber, PdfDestination } from "@embedpdf/core";
2
- import { PageRotation, PageTransform, Rect } from "@embedpdf/core-geometry";
3
- import { Align, AlignValue, Alignment, Alignment as Alignment$1, AlignmentValue, Anchor, Camera, Direction, Direction as Direction$1, PageBox, PageFrame, PageFrame as PageFrame$1, Point, ScrollMetrics, ScrollMetrics as ScrollMetrics$1, Size, SizingMode, SizingMode as SizingMode$1, SpreadMode, SpreadMode as SpreadMode$1, ZoomMode, ZoomModeValue, ZoomModeValue as ZoomModeValue$1, ZoomSpec, ZoomSpec as ZoomSpec$1 } from "@embedpdf/core-stage";
4
- import { InteractionCapability, InteractionHandler } from "@embedpdf/plugin-interaction";
5
- //#region src/types.d.ts
6
- type LayoutKind = 'vertical' | 'horizontal' | 'grid';
7
- /** Navigation (goToPage) either tweens the camera or jumps instantly. */
8
- type ScrollBehaviorKind = 'smooth' | 'instant';
9
- /**
10
- * Presentation flow:
11
- * 'continuous' — the whole document is scrollable; the camera roams the full scene.
12
- * 'paged' — one item (page or spread) at a time: the scene is a one-item
13
- * slice at the cursor, and next/prev step between items.
14
- */
15
- type FlowMode = 'continuous' | 'paged';
16
- /**
17
- * Grid column policy:
18
- * 'square' — ≈√n columns (the classic canvas arrangement)
19
- * 'auto' — WRAPPED: as many columns as fit the viewport line at the current
20
- * zoom (the responsive thumbnail-sidebar behavior; re-wraps on resize)
21
- * number — a fixed column count
22
- */
23
- type GridColumns = 'square' | 'auto' | number;
24
- /**
25
- * Space between items — the value's shape carries the unit (like ZoomSpec):
26
- * number — WORLD units: the gap is part of the canvas and scales with zoom,
27
- * so the whole scene zooms as one rigid object (the document feel).
28
- * { px: n } — SCREEN px: UI-stable spacing, the same in every document at every
29
- * zoom (the browser-of-items feel: thumbnails, organizers).
30
- */
31
- type Gap = number | {
32
- px: number;
33
- };
34
- /**
35
- * The one environmental fact a headless stage has: the box it was told about
36
- * (`setViewport`). Responsive rules can query nothing else — no user agent, no
37
- * pointer type (modality is per-event, on `PointerSample`), no window. Space,
38
- * not device: a narrow pane on a desktop is compact too, and each stage
39
- * instance resolves against ITS OWN box.
40
- */
41
- interface StageBox {
42
- width: number;
43
- height: number;
44
- /** Of the CONTAINER, not the device. A square box is 'portrait' (the CSS rule). */
45
- orientation: 'portrait' | 'landscape';
46
- }
47
- /** Declarative box query — all bounds inclusive, all fields optional (AND-ed). */
48
- interface BoxQuery {
49
- minWidth?: number;
50
- maxWidth?: number;
51
- minHeight?: number;
52
- maxHeight?: number;
53
- orientation?: 'portrait' | 'landscape';
54
- }
55
- /**
56
- * One `@container` block for the settings bag: when the box matches, assert
57
- * this settings patch. Rules evaluate in source order and ALL matching rules
58
- * apply, later winning per key (each key replaced whole — no deep merges).
59
- * Effective settings = base (config + runtime setters) ⊕ matching patches.
60
- *
61
- * Semantics, stated honestly:
62
- * • Runtime setters write the BASE; a matching rule wins over it. Apps
63
- * needing situational absolute control edit the rules (`setResponsive`).
64
- * • Rules assert at TRANSITIONS (box/base/rules changes), not continuously —
65
- * between crossings, interaction owns the state. A rule containing `zoom`
66
- * re-fits when the box crosses it (the rotate-an-iPad behavior) and then
67
- * leaves the pinch alone.
68
- *
69
- * A rule with a `name` is a queryable fact (`matches(name)`), reactive in
70
- * every framework; a named rule with NO settings is a pure shared breakpoint
71
- * the app chrome can key its own presentation off — one definition serving
72
- * both the layout math and the UI.
73
- */
74
- interface ResponsiveRule {
75
- name?: string;
76
- /** Declarative box query, or a predicate for anything the box can answer. */
77
- when: BoxQuery | ((box: StageBox) => boolean);
78
- /** The settings this situation asserts. Omit for a pure named query. */
79
- settings?: Partial<StageSettings>;
80
- }
81
- /**
82
- * One axis of the ARRIVAL policy — stage-core's AlignValue ('start' |
83
- * 'center' | 'end' | viewport fraction 0–1) plus one navigation-only word:
84
- * 'keep' — this axis does not move on arrival: page forward, hold your
85
- * pan (the two-column-paper feel; the PDF /XYZ null semantic).
86
- */
87
- type ArrivalAlignValue = AlignValue | 'keep';
88
- interface ArrivalAlignment {
89
- x: ArrivalAlignValue;
90
- y: ArrivalAlignValue;
91
- }
92
- /**
93
- * The Stage's orthogonal, independently-settable primitives. Every field can be set
94
- * on its own (setLayout, setBounded, …) or several at once via `update()`. A
95
- * "preset" is just a `Partial<StageSettings>` the app keeps and applies — no preset
96
- * machinery lives here.
97
- */
98
- interface StageSettings {
99
- /** Continuous scroll, or one item at a time. */
100
- flow: FlowMode;
101
- layout: LayoutKind;
102
- spread: SpreadMode$1;
103
- /** Page sizing: true PDF sizes, or equalize the cross axis so pages sit flush. */
104
- sizing: SizingMode$1;
105
- /** Grid column policy (grid layout only): 'square', 'auto' (wrapped), or a count. */
106
- columns: GridColumns;
107
- /** Clamp the camera to the content? Off = free infinite pan (plans / CAD). */
108
- bounded: boolean;
109
- /**
110
- * Breathing room (screen px) around the content — the one spacing concept.
111
- * Fit-modes inset by it, arrivals leave it as a gutter, and the clamp lets the
112
- * camera reveal exactly this much beyond each content edge.
113
- */
114
- padding: number;
115
- /**
116
- * Space BETWEEN items — and between the halves of a spread. A number is world
117
- * units (scales with zoom — the canvas feel); `{ px }` is screen px (UI-stable
118
- * — the thumbnail feel). See {@link Gap}.
119
- */
120
- gap: Gap;
121
- /**
122
- * Reserved chrome real estate around EACH PAGE, in SCREEN px — one thickness
123
- * per side. The page content is inset by these; the bands hold box-space
124
- * chrome (a label below, a button row above, side rails) painted by the app
125
- * via the adapter's `pageChrome` slot. Per page, not per item: in a spread
126
- * every page keeps its own flanks. Constant screen px (unaffected by zoom).
127
- *
128
- * Naming rule for this settings bag: every setting describes the STAGE itself
129
- * (the container) — `padding`, `gap`, `layout`, … The rare setting owned by the
130
- * page carries the `page` prefix (`pageFrame`; `pageWidth` in zoom).
131
- */
132
- pageFrame: PageFrame$1;
133
- /**
134
- * Reading direction. RTL: horizontal items advance leftward, spreads bind on the
135
- * right, grid rows fill right→left, and alignment 'start' on x means the RIGHT
136
- * edge (logical, CSS-style). Navigation is index-based and never changes.
137
- */
138
- direction: Direction$1;
139
- /**
140
- * The alignment family — EVERY camera move is defined by what it holds
141
- * fixed. Gestures (pan/pinch/wheel) hold the pointer: physics, no setting.
142
- * Explicit arrivals (positioned reveal, destinations, viewpoints) hold
143
- * whatever the call specifies. These four settings govern the rest:
144
- *
145
- * fitAlign — the standing CONSTRAINT: where content rests on an axis
146
- * the camera cannot travel (it fits the TRUE bounds — the
147
- * scene in continuous flow, the item slice in paged). The
148
- * clamp enforces it on every camera write — which is why a
149
- * fitting axis settles identically whatever arrivalAlign
150
- * says. center/center = document feel; y:'start' = sidebar
151
- * thumbnails hugging the top.
152
- * arrivalAlign — the landing POLICY: where navigation (goToPage, next/
153
- * prev, reset) puts the target — THE SAME at every zoom.
154
- * start/start = reading (top-left, direction-aware);
155
- * center/center = presentation/drawings (Drawboard feel);
156
- * y: 0.35 = the find-bar line; 'keep' = don't move an axis.
157
- * zoomAlign — the FOCAL point of a pointer-less zoom (zoomIn/zoomOut,
158
- * zoomTo, fit-mode switches). Pinch/ctrl+wheel always hold
159
- * the pointer instead — that is physics, not policy.
160
- * center/center = the view inflates around its middle;
161
- * y:'start' = the first visible line holds still.
162
- * anchorAlign — the viewport point that SURVIVES a reframe (viewport
163
- * resize, page rotation, spread/gap change): the view
164
- * anchor is captured there and restored there. start/start
165
- * = the browser scroll model (growth reveals below — a
166
- * container that mounts small and expands never shoves the
167
- * document down); center/center = canvas-style symmetric
168
- * resizes (the Figma feel).
169
- *
170
- * Named x values are LOGICAL (CSS-style: 'start' = reading start — the
171
- * right edge in RTL); fractions are physical, like screen coordinates.
172
- */
173
- fitAlign: Alignment$1;
174
- /** See {@link StageSettings.fitAlign} — where navigation lands, per axis. */
175
- arrivalAlign: ArrivalAlignment;
176
- /** See {@link StageSettings.fitAlign} — the pointer-less zoom focal point. */
177
- zoomAlign: AlignmentValue;
178
- /** See {@link StageSettings.fitAlign} — the viewport point reframes hold. */
179
- anchorAlign: AlignmentValue;
180
- /**
181
- * NON-PERSISTENT view rotation: a quarter-turn (clockwise) applied to how
182
- * EVERY page is DISPLAYED in this lens, on top of each page's own /Rotate —
183
- * Adobe's "Rotate View". A display setting like `zoom` or `layout`: per lens
184
- * (the main viewer can rotate while a thumbnail lens stays upright), never
185
- * written to the document, gone when the lens resets. The PERMANENT
186
- * counterpart — writing /Rotate into the PDF — is plugin-page-edit's
187
- * `rotateBy`/`setRotation`.
188
- */
189
- viewRotation: PageRotation;
190
- /** Zoom intent: a fit-mode (automatic/fit-page/fit-width/fit-all) or a fixed level. */
191
- zoom: ZoomSpec$1;
192
- /** Default behaviour for goToPage/next/prev. */
193
- scrollBehavior: ScrollBehaviorKind;
194
- /**
195
- * View pixels per PDF point — the platform's physical unit factor, folded into
196
- * the layout so 100% (zoom 1) is physically accurate. Web = 96/72 (1 pt = 1/72",
197
- * 1 CSS px = 1/96"); a native platform injects its own (iOS pt, Android dp). It
198
- * scales every page's world size (and thus `contentScale`), so the camera math,
199
- * `gap`/`padding`/`pageFrame` (world units), and absolute-px zoom modes
200
- * (`pageWidth`) are all unaffected — only the pages themselves resize.
201
- */
202
- viewUnitsPerPoint: number;
203
- }
204
- /**
205
- * A laid-out page handed to the shell.
206
- * - PageBox + `pon`: LAYOUT truth (world coords + identity) — the shell uses
207
- * `x/y/width/height` only to POSITION the page container.
208
- * - `transform`: PRESENTATION truth — the single bridge between PDF points,
209
- * view px, and device px for this page. Plugins do ALL coordinate work
210
- * through it (`contentToView` / `viewToContent` / `deviceWidth` / `cssMatrix`),
211
- * never by re-deriving `x * scale` / `* dpr`. Page-local, so it's
212
- * camera/pan-invariant.
213
- */
214
- interface VisiblePage extends PageBox {
215
- pon: PageObjectNumber;
216
- /**
217
- * The page's DISPLAY-box (footprint) top-left in screen px, camera-resolved and
218
- * snapped to the device grid. The shell positions the page container at this —
219
- * snapping here (not in the adapter) keeps a CSS-rotated page on the pixel grid
220
- * for every framework, with no hand-rounding.
221
- */
222
- screenX: number;
223
- screenY: number;
224
- transform: PageTransform;
225
- /**
226
- * The page region actually ON SCREEN, in UN-rotated page points (y-down) —
227
- * viewport ∩ footprint inverted through the transform (exact for
228
- * quarter-turns). Zero-sized when the page sits outside the viewport.
229
- * Visibility is the STAGE's data (it already intersects viewport × pages to
230
- * virtualize); adapters and demand consumers (tiling's `PageViewDemand`)
231
- * read it instead of re-deriving camera math per framework.
232
- */
233
- visibleRect: Rect;
234
- }
235
- interface StageState extends StageSettings {
236
- camera: Camera;
237
- /**
238
- * One-way render-commit latch. False while the initial viewport-driven
239
- * placement is unresolved; true only after its camera/settings writes have
240
- * completed. Page/scroll screen-space selectors refuse to answer while
241
- * false, so an adapter can never paint the placeholder camera at the origin.
242
- */
243
- placed: boolean;
244
- /**
245
- * Names of the responsive rules currently matching the box, in source order.
246
- * State (not derived) so `matches()` is reactive through the ordinary
247
- * selector machinery in every framework.
248
- */
249
- activeRules: readonly string[];
250
- /**
251
- * False while the ZOOM is in motion, true once it has rested (~150ms of
252
- * frames without a zoom write). Device-snapping of page origins is gated
253
- * on this: a continuous zoom and a snapped origin cannot coexist without
254
- * the anchor point jittering ±0.5 device px per step (the rounding lands
255
- * differently every frame), so pages place fractionally while zooming and
256
- * snap once at rest — when crispness actually matters. Pans always snap
257
- * (a pure translation snap has no anchor error). Transient like `camera`.
258
- */
259
- cameraResting: boolean;
260
- vp: Size;
261
- /**
262
- * Device pixels per view pixel (web: `window.devicePixelRatio`). Reported by
263
- * the shell like the viewport; feeds each page's transform so bitmaps render
264
- * crisp (exact device px) and boxes land on the device grid. Defaults to 1.
265
- */
266
- dpr: number;
267
- /**
268
- * The current page — transient like `camera` (NOT a setting), valid in BOTH flows.
269
- * Navigation sets it; in continuous flow scrolling syncs it from the camera; in
270
- * paged flow panning never moves it (the scene is a one-item slice at this page).
271
- * Stored as a page index so it survives spread/layout regrouping.
272
- */
273
- cursor: number;
274
- }
275
- type StageAction = {
276
- type: 'CAMERA';
277
- camera: Camera;
278
- } | {
279
- type: 'CAMERA_REST';
280
- resting: boolean;
281
- } | {
282
- type: 'PLACED';
283
- } | {
284
- type: 'VP';
285
- vp: Size;
286
- } | {
287
- type: 'DPR';
288
- dpr: number;
289
- } | {
290
- type: 'CURSOR';
291
- cursor: number;
292
- } | {
293
- type: 'PATCH';
294
- patch: Partial<StageSettings>;
295
- } | {
296
- type: 'RESPONSIVE';
297
- active: readonly string[];
298
- };
299
- /**
300
- * A page-relative view memento: "what I'm looking at and how zoomed". The durable
301
- * currency for per-page view memory (construction worksheets) — capture with
302
- * `viewpoint()`, restore with `goToPage(i, { viewpoint })`. Survives resizes
303
- * because the anchor is page-relative and fit-modes re-resolve.
304
- */
305
- interface Viewpoint {
306
- anchor: Anchor;
307
- zoom: ZoomSpec$1;
308
- }
309
- /** Durable, serializable view state — the unit of session persistence. */
310
- interface StageViewState extends StageSettings {
311
- cursor: number;
312
- anchor: Anchor;
313
- }
314
- /**
315
- * Host timing seam. The pure core (stage-core) never touches time; the camera tween
316
- * lives in this (impure) shell and asks for frames through a Scheduler. The default
317
- * is the browser's requestAnimationFrame; inject a fake in tests, or an instant one
318
- * in Node/SSR.
319
- */
320
- interface Scheduler {
321
- /** Run the callback on the next frame; returns a handle for cancellation. */
322
- raf(callback: (timestampMs: number) => void): number;
323
- /** Cancel a scheduled callback. */
324
- caf(handle: number): void;
325
- }
326
- /**
327
- * Options for the scroller writes — `Element.scrollTo` semantics: absolute
328
- * offsets (screen px) into the current scroll range (see
329
- * {@link StageCapability.scrollMetrics}); an omitted axis does not move.
330
- * `behavior` defaults to 'instant' (the DOM's 'auto'), NOT the stage's
331
- * `scrollBehavior` setting — that setting governs navigation verbs, and a
332
- * scrollbar thumb must track the pointer exactly.
333
- */
334
- interface StageScrollToOptions {
335
- left?: number;
336
- top?: number;
337
- behavior?: ScrollBehaviorKind;
338
- }
339
- /** Options for navigation intents. */
340
- interface GoToOptions {
341
- behavior?: ScrollBehaviorKind;
342
- /** Restore this exact viewpoint instead of fresh placement (per-page memory). */
343
- viewpoint?: Viewpoint;
344
- /** Override the landing for THIS navigation only (explicit beats default). */
345
- arrivalAlign?: Partial<ArrivalAlignment>;
346
- }
347
- /**
348
- * One axis of a reveal arrival — `scrollIntoView` vocabulary plus two
349
- * PDF-protocol necessities:
350
- * absent → minimal movement: scroll only if the target is off-screen
351
- * (CSS 'nearest'; today's reveal semantics)
352
- * 'keep' → this axis does not move AT ALL (PDF /XYZ null coordinate)
353
- * 'start' → target edge at the viewport start (plus padding)
354
- * 'center' → target centered
355
- * 'end' → target edge at the viewport end (minus padding)
356
- * number 0–1 → target CENTER at this viewport fraction (0.35 = "top middle",
357
- * the browser find-bar feel)
358
- */
359
- type RevealAnchorValue = 'keep' | 'start' | 'center' | 'end' | number;
360
- interface RevealAnchor {
361
- x?: RevealAnchorValue;
362
- y?: RevealAnchorValue;
363
- }
364
- /**
365
- * What happens to zoom on a reveal — always relative to the reveal's target
366
- * rect (the whole page when no `rect` is given):
367
- * 'keep' → pure pan, zoom untouched (search hits, /XYZ null zoom)
368
- * { level } → explicit factor (/XYZ zoom)
369
- * 'fit' → the rect fully visible (/FitR; /Fit, /FitB via rect=page/bbox)
370
- * 'fit-width' → the rect's width fills the viewport (/FitH, /FitBH)
371
- * 'fit-height' → the rect's height fills the viewport (/FitV, /FitBV)
372
- */
373
- type RevealZoom = 'keep' | 'fit' | 'fit-width' | 'fit-height' | {
374
- level: number;
375
- };
376
- /**
377
- * Options for `reveal` — the follower-UI arrival verb (search hits, outline
378
- * clicks, PDF destinations, "jump to comment").
379
- *
380
- * With none of `rect`/`zoom`/`anchor` set, reveal keeps its original
381
- * semantics: minimal movement to make the page visible, cursor untouched.
382
- * A POSITIONED reveal (any of the three set) is "you are now looking at
383
- * THIS spot": the camera places the target per the anchor, a zoom
384
- * directive resolves to a concrete level (recorded as the zoom intent),
385
- * and the cursor follows the camera — while still clamping against the
386
- * normal camera bounds, so anchors are best-effort near document edges.
387
- */
388
- interface RevealOptions {
389
- behavior?: ScrollBehaviorKind;
390
- /**
391
- * Target rect on the page in the VIEWER's coordinates (y-down,
392
- * crop-relative, unscaled points — the same `Rect` selection/search rects
393
- * and `CommentThreadView.contentRect` live in). Absent or `null` → the
394
- * whole page (null accepted so nullable sources flow in directly). A
395
- * zero-size rect is a point (/XYZ).
396
- */
397
- rect?: Rect | null;
398
- zoom?: RevealZoom;
399
- anchor?: RevealAnchor;
400
- }
401
- /** The Stage's public contract: selectors (reads) + intents (the only writers). */
402
- interface StageCapability {
403
- camera(): Camera;
404
- viewport(): Size;
405
- /**
406
- * The camera as a NATIVE SCROLLER — the DOM scroll vocabulary in screen px:
407
- * `scrollTop`/`scrollHeight`/`clientHeight` (and the x twins) mean exactly
408
- * what they mean on a DOM element; `scrollableX/Y` false ⇔ nothing to scroll
409
- * on that axis (native: no bar). Derived from the SAME travel range the pan
410
- * clamp uses — paged flow reads the one-item slice — so a scrollbar built on
411
- * it can never disagree with where panning stops. On an UNBOUNDED stage the
412
- * range is the union of the padded content and the current window (the Figma
413
- * bar): pan away and it grows, the thumb shrinking toward the edge but always
414
- * remaining a road back. Reference-stable until a field actually changes.
415
- */
416
- scrollMetrics(): ScrollMetrics$1;
417
- pageCount(): number;
418
- visiblePages(): VisiblePage[];
419
- /** The current page (the cursor) — valid in both flows. */
420
- currentPage(): number;
421
- /** The display indices of the current item's pages (1 page, or a spread's pages). */
422
- currentItemPages(): number[];
423
- /** The full page list with PDF labels — for page thumbnails / worksheet tabs. */
424
- pages(): Array<{
425
- index: number;
426
- pon: PageObjectNumber;
427
- label: string | null;
428
- }>;
429
- /** The laid-out box for a page by its durable pon. */
430
- pageRect(pon: PageObjectNumber): VisiblePage | null;
431
- /**
432
- * Screen point (this Stage's container px) → the page under it + its content
433
- * point, or null over a gap. The viewport-level hit-test the interaction hub
434
- * needs so a single pointer source can drive page-aware features (text
435
- * selection, annotations) AND cross-page drags.
436
- */
437
- pageAt(screen: Point): {
438
- pon: PageObjectNumber;
439
- point: Point;
440
- scale: number;
441
- /** The hit page's TOTAL display rotation (document /Rotate + view rotation). */
442
- rotation: PageRotation;
443
- /** The hit page's zoom relative to its 100% baseline (`transform.zoom`). */
444
- zoom: number;
445
- } | null;
446
- /**
447
- * Screen point → `pon`'s content space, UNCLAMPED — valid even when the point
448
- * is outside the page's bounds (coordinates then fall outside `[0, size]`).
449
- * The frame-stable projection a page-anchored gesture (annotation move/resize)
450
- * tracks with, where `pageAt` would re-resolve to whatever page is under the
451
- * cursor (what a cross-page drag like text selection wants). Null when the
452
- * page isn't currently laid out.
453
- */
454
- pointOnPage(pon: PageObjectNumber, screen: Point): Point | null;
455
- /**
456
- * Page space (intrinsic PDF points) → world space. Applies the page's placed
457
- * origin and contentScale — the transform sizing policies introduce. Compose
458
- * with toScreen for viewport-space overlays anchored to page content.
459
- */
460
- pageToWorld(pon: PageObjectNumber, pt: Point): Point | null;
461
- /**
462
- * Content rect on a page → this Stage viewport's screen-space AABB. Applies page
463
- * rotation/contentScale and the current camera. Use for upright viewport overlays
464
- * that need to frame a selected page region.
465
- */
466
- pageRectToScreen(pon: PageObjectNumber, rect: Rect): Rect | null;
467
- toScreen(world: Point): Point;
468
- toWorld(screen: Point): Point;
469
- flow(): FlowMode;
470
- layout(): LayoutKind;
471
- spread(): SpreadMode$1;
472
- sizing(): SizingMode$1;
473
- columns(): GridColumns;
474
- bounded(): boolean;
475
- padding(): number;
476
- gap(): Gap;
477
- pageFrame(): PageFrame$1;
478
- fitAlign(): Alignment$1;
479
- arrivalAlign(): ArrivalAlignment;
480
- zoomAlign(): AlignmentValue;
481
- anchorAlign(): AlignmentValue;
482
- direction(): Direction$1;
483
- scrollBehavior(): ScrollBehaviorKind;
484
- /** The lens's view rotation — see {@link StageSettings.viewRotation}. */
485
- viewRotation(): PageRotation;
486
- zoomLevel(): number;
487
- /** The active zoom intent: a fit-mode, or 'custom' for a fixed level. */
488
- zoomMode(): ZoomModeValue$1 | 'custom';
489
- /** What I'm looking at + zoom intent — capture for per-page view memory. */
490
- viewpoint(): Viewpoint;
491
- /** A snapshot of all settings (handy for building/saving a customer preset). */
492
- settings(): StageSettings;
493
- viewState(): StageViewState;
494
- setViewport(vp: Size): void;
495
- /** Report the device pixel ratio (web: `devicePixelRatio`). The shell calls
496
- * this once on mount and whenever it changes (e.g. dragging between monitors)
497
- * so page transforms render crisp. */
498
- setDevicePixelRatio(dpr: number): void;
499
- setCamera(c: Camera): void;
500
- panBy(dxScreen: number, dyScreen: number): void;
501
- /** `Element.scrollTo` for the camera: absolute offsets into the scroll range
502
- * (see {@link StageScrollToOptions}) — clamped into it, cursor-synced, zoom
503
- * untouched (scrolling is a pan in scroller clothing). */
504
- scrollTo(opts: StageScrollToOptions): void;
505
- /** `Element.scrollBy`: relative offsets — sugar over `scrollTo`. */
506
- scrollBy(opts: StageScrollToOptions): void;
507
- zoomAround(screenPt: Point, factor: number): void;
508
- /**
509
- * Bracket a continuous direct-manipulation gesture (touch pan / pinch).
510
- * While a gesture is open the camera writes stay cheap and visually calm:
511
- * `zoomAround` defers its zoom-intent PATCH (one per gesture instead of one
512
- * per event), and the camera-rest detector holds un-rested — device
513
- * snapping and settle-gated rendering wait for the END of the gesture, not
514
- * for a 150 ms hesitation inside it. Re-entrant (nesting counts). Opening a
515
- * gesture cancels any running tween or fling — that is how a finger
516
- * "catches" a moving page.
517
- *
518
- * `elastic` opts the gesture into RUBBER-BAND overscroll: pans past the
519
- * clamp stretch on the iOS resistance curve instead of stopping dead, and
520
- * ending the gesture (or a fling reaching an edge) springs the camera home
521
- * on a critically-damped curve. The clamp itself stays the untouched law of
522
- * REST — elasticity is a transient the gesture is allowed to hold, never a
523
- * state the camera can settle in. Touch contacts pass it; mouse drags and
524
- * wheel pans stay rigid (the desktop convention). Default false.
525
- */
526
- beginGesture(options?: {
527
- elastic?: boolean;
528
- }): void;
529
- endGesture(): void;
530
- /**
531
- * Momentum scroll: keep panning from a release velocity (screen px/s, the
532
- * same sign convention as `panBy` deltas), decelerating on UIScrollView's
533
- * curve. Every other camera verb — including `beginGesture` from the next
534
- * touch — cancels it. No-op without host frames (SSR/tests without a
535
- * scheduler jump nowhere: momentum is presentation, not state).
536
- */
537
- fling(velocityX: number, velocityY: number): void;
538
- /** True while the camera is animating (navigation tween or fling) — the
539
- * input layer reads it to tell a "catch" from a tap. */
540
- cameraInMotion(): boolean;
541
- /**
542
- * The touch double-tap toggle: zoomed out → animate to ~2.5× the automatic
543
- * fit around `screenPt`; already zoomed past that → animate back to the fit
544
- * level, same focal point. Lands as a fixed zoom level either way.
545
- */
546
- doubleTapZoom(screenPt: Point): void;
547
- zoomIn(): void;
548
- zoomOut(): void;
549
- zoomTo(spec: ZoomSpec$1): void;
550
- fitWidth(): void;
551
- fitPage(): void;
552
- /** Fit the whole scene (every page) in view — the construction overview. */
553
- fitAll(): void;
554
- /** Fit width but never upscale past 100% (Adobe's "Automatic"). */
555
- automatic(): void;
556
- /**
557
- * Re-resolve the active zoom intent and re-place against the CURRENT scene,
558
- * preserving the anchored page-point. Call after the page geometry changes
559
- * underneath the lens — rotate/move/delete — so fit/pixel zoom modes
560
- * (`fitPage`, `pageWidth`, …) recompute against the new footprint. A no-op
561
- * before the first placement; for a fixed `{ level }` zoom it just re-anchors.
562
- * Wired automatically to the document's page-registry revision; exposed for
563
- * any external geometry change a host wants to react to.
564
- */
565
- refit(): void;
566
- /** Go to a page. Fresh arrival places by the unit rule; pass `viewpoint` to restore. */
567
- goToPage(pageIndex: number, opts?: GoToOptions): void;
568
- /**
569
- * The follower-UI arrival verb (thumbnail sidebars, search hits, outline
570
- * clicks, PDF destinations). Bare: make the page visible with minimal
571
- * movement — zero if it already is, cursor untouched (scrollIntoView
572
- * semantics; paged flow delegates to navigation since the page isn't in
573
- * the slice). POSITIONED (rect/zoom/anchor set — see {@link RevealOptions}):
574
- * place the target at the anchor, optionally re-zooming; the cursor
575
- * follows the camera.
576
- */
577
- reveal(pageIndex: number, opts?: RevealOptions): void;
578
- /** Step forward by the navigation unit (the item if it fits the viewport, else the page). */
579
- next(opts?: GoToOptions): void;
580
- /** Step backward by the navigation unit. */
581
- prev(opts?: GoToOptions): void;
582
- /**
583
- * This lens's identity — the stage plugin id it was registered under
584
- * ('stage' for the main lens; a custom id per additional lens). The surface
585
- * binding stamps it on every pointer sample (`PointerSample.source`) and
586
- * lens-scoped interaction handlers register under it, so two stages on one
587
- * document can never capture each other's input.
588
- */
589
- lensId(): string;
590
- /** Set any subset of settings at once — ONE anchor-preserving update. The way to
591
- * apply a customer preset: `update(myPreset)`. Writes the responsive BASE:
592
- * a matching rule's key wins until its rule stops matching. */
593
- update(patch: Partial<StageSettings>): void;
594
- /** Replace the responsive rules (see {@link ResponsiveRule}); re-resolves
595
- * immediately with the usual anchor-preserving reactions. */
596
- setResponsive(rules: readonly ResponsiveRule[]): void;
597
- /** Is the named responsive rule currently matching? Reactive: recomputed
598
- * whenever the box crosses a rule boundary. */
599
- matches(name: string): boolean;
600
- /** Names of all currently-matching rules, in source order. */
601
- activeRules(): readonly string[];
602
- setFlow(flow: FlowMode): void;
603
- setLayout(layout: LayoutKind): void;
604
- setSpread(spread: SpreadMode$1): void;
605
- setSizing(sizing: SizingMode$1): void;
606
- setColumns(columns: GridColumns): void;
607
- setBounded(bounded: boolean): void;
608
- setPadding(padding: number): void;
609
- setGap(gap: Gap): void;
610
- setPageFrame(pageFrame: PageFrame$1): void;
611
- setFitAlign(fitAlign: Alignment$1): void;
612
- setArrivalAlign(arrivalAlign: ArrivalAlignment): void;
613
- setZoomAlign(zoomAlign: AlignmentValue): void;
614
- setAnchorAlign(anchorAlign: AlignmentValue): void;
615
- setDirection(direction: Direction$1): void;
616
- /** Set the lens's view rotation to an absolute quarter-turn — see
617
- * {@link StageSettings.viewRotation}. An anchor-preserving reframe, like a
618
- * page rotation: the spot you were looking at stays put (`anchorAlign`). */
619
- setViewRotation(viewRotation: PageRotation): void;
620
- /** Rotate the view a quarter-turn from where it is (the toolbar verb) —
621
- * relative sugar over {@link setViewRotation}, mirroring page-edit's `rotateBy`. */
622
- rotateView(delta: 90 | -90): void;
623
- setScrollBehavior(behavior: ScrollBehaviorKind): void;
624
- applyViewState(view: StageViewState): void;
625
- /** Offer a candidate initial view; the highest-priority non-null wins at placement. */
626
- provideInitialView(priority: number, provider: () => StageViewState | null): void;
627
- /** Resolve the registered providers once (else reset). Called when the viewport is ready. */
628
- placeInitial(): void;
629
- /** Back to the start: page 0, placed by the unit rule at the current zoom intent. */
630
- resetView(): void;
631
- }
632
- interface StageConfig extends Partial<StageSettings> {
633
- /** Override the host timing seam (tests/SSR). Defaults to browser rAF. */
634
- scheduler?: Scheduler;
635
- /**
636
- * Container queries for the settings bag (see {@link ResponsiveRule}).
637
- * Defaults to `DEFAULT_RESPONSIVE` (compact containers get the thin phone
638
- * gutter); pass `[]` to opt out entirely.
639
- */
640
- responsive?: readonly ResponsiveRule[];
641
- }
642
- declare const StageToken: import("@embedpdf/core").CapabilityToken<StageCapability>;
643
- //#endregion
1
+ import { C as Viewpoint, S as StageViewState, _ as StageConfig, a as GridColumns, b as StageState, c as RevealAnchor, d as RevealZoom, f as Scheduler, g as StageCapability, h as StageBox, i as GoToOptions, l as RevealAnchorValue, m as StageAction, n as FlowMode, o as LayoutKind, p as ScrollBehaviorKind, r as Gap, s as ResponsiveRule, t as BoxQuery, u as RevealOptions, v as StageScrollToOptions, w as VisiblePage, x as StageToken, y as StageSettings } from "./types-qdO_v-V-.cjs";
2
+ import { Align, Alignment, Direction, PageFrame, ScrollMetrics, SizingMode, SpreadMode, ZoomMode, ZoomModeValue, ZoomSpec } from "./contract.cjs";
3
+ import { DestinationReveal, destinationToReveal } from "./destination.cjs";
4
+ import { CapabilityToken } from "@embedpdf/core";
5
+ import { Size } from "@embedpdf/core-stage";
6
+ import { InteractionCapability, InteractionHandler } from "@embedpdf/plugin-interaction/contract";
644
7
  //#region src/stage.plugin.d.ts
645
8
  /**
646
9
  * Options for registering a stage instance. The Stage is a LENS, not a singleton:
@@ -669,20 +32,6 @@ interface StagePluginOptions extends StageConfig {
669
32
  */
670
33
  declare const stagePlugin: (options?: StagePluginOptions) => import("@embedpdf/core").PluginDef<StageState, StageAction, StageCapability>;
671
34
  //#endregion
672
- //#region src/destination.d.ts
673
- interface DestinationReveal {
674
- /** Display index for `reveal()` — from the layout row. */
675
- pageIndex: number;
676
- options: RevealOptions;
677
- }
678
- /**
679
- * Translate one explicit destination against its target page's layout.
680
- * `bbox` is the page's content BOUNDING box in CONTENT space, for the
681
- * `/FitB*` kinds — pass it when known; the crop box is the spec-tolerated
682
- * fallback until the engine exposes it.
683
- */
684
- declare function destinationToReveal(dest: PdfDestination, layout: PageLayout, bbox?: Rect): DestinationReveal;
685
- //#endregion
686
35
  //#region src/scroll-handler.d.ts
687
36
  interface ScrollHandlerOptions {
688
37
  /**