@embedpdf/plugin-stage 3.0.0-next.13 → 3.0.0-next.15

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