@embedpdf/plugin-stage 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.
@@ -0,0 +1,575 @@
1
+ import { CapabilityToken, EventHook, PageDestination, PageInfo, PageRef } from "@embedpdf/core";
2
+ import { PageRotation, PageTransform, Rect } from "@embedpdf/core-geometry";
3
+ import { Align, AlignValue, AlignValue as AlignValue$1, Alignment, Alignment as Alignment$1, AlignmentValue, AlignmentValue as AlignmentValue$1, Anchor, Camera, Camera as Camera$1, Direction, Direction as Direction$1, PageBox, PageFrame, PageFrame as PageFrame$1, Point, Point as Point$1, ScrollMetrics, Size, Size as Size$1, 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
+ //#region src/token.d.ts
5
+ declare const StageToken: import("@embedpdf/core").CapabilityToken<StageCapability>;
6
+ //#endregion
7
+ //#region src/contract.d.ts
8
+ type LayoutKind = 'vertical' | 'horizontal' | 'grid';
9
+ /** Navigation (goToPage) either tweens the camera or jumps instantly. */
10
+ type ScrollBehaviorKind = 'smooth' | 'instant';
11
+ /**
12
+ * Presentation flow:
13
+ * 'continuous' — the whole document is scrollable; the camera roams the full scene.
14
+ * 'paged' — one item (page or spread) at a time: the scene is a one-item
15
+ * slice at the cursor, and nextPage/previousPage step between items.
16
+ */
17
+ type FlowMode = 'continuous' | 'paged';
18
+ /**
19
+ * Grid column policy:
20
+ * 'square' — ≈√n columns (the classic canvas arrangement)
21
+ * 'auto' — wrapped: as many columns as fit the viewport line at the current
22
+ * zoom (the responsive thumbnail-sidebar behavior; re-wraps on resize)
23
+ * number — a fixed column count
24
+ */
25
+ type GridColumns = 'square' | 'auto' | number;
26
+ /**
27
+ * Space between items — the value's shape carries the unit (like ZoomSpec):
28
+ * number — world units: the gap is part of the canvas and scales with zoom,
29
+ * so the whole scene zooms as one rigid object (the document feel).
30
+ * { px: n } — screen px: UI-stable spacing, the same in every document at every
31
+ * zoom (the browser-of-items feel: thumbnails, organizers).
32
+ */
33
+ type Gap = number | {
34
+ px: number;
35
+ };
36
+ /**
37
+ * The one environmental fact a headless stage has: the box it was told about
38
+ * (`setViewportSize`). Responsive rules can query nothing else — no user agent, no
39
+ * pointer type (modality is per-event, on `PointerSample`), no window. Space,
40
+ * not device: a narrow pane on a desktop is compact too, and each stage
41
+ * instance resolves against its own box.
42
+ */
43
+ interface StageBox {
44
+ width: number;
45
+ height: number;
46
+ /** Of the container, not the device. A square box is 'portrait' (the CSS rule). */
47
+ orientation: 'portrait' | 'landscape';
48
+ }
49
+ /** Declarative box query: all bounds inclusive, all fields optional, every condition must hold. */
50
+ interface BoxQuery {
51
+ minWidth?: number;
52
+ maxWidth?: number;
53
+ minHeight?: number;
54
+ maxHeight?: number;
55
+ orientation?: 'portrait' | 'landscape';
56
+ }
57
+ /**
58
+ * One `@container` block for the settings bag: when the box matches, assert
59
+ * this settings patch. Rules evaluate in source order and all matching rules
60
+ * apply, later winning per key (each key replaced whole — no deep merges).
61
+ * Effective settings = base (config + `updateSettings()`) ⊕ matching patches.
62
+ *
63
+ * Semantics:
64
+ * • `updateSettings()` writes the base; a matching rule wins over it. Apps
65
+ * needing situational absolute control edit the rules (`setResponsiveRules`).
66
+ * • Rules assert at transitions (box/base/rules changes), not continuously —
67
+ * between crossings, interaction owns the state. A rule containing `zoom`
68
+ * re-fits when the box crosses it (the rotate-an-iPad behavior) and then
69
+ * leaves the pinch alone.
70
+ *
71
+ * A rule with a `name` is a queryable fact (`matchesRule(name)`), reactive in
72
+ * every framework; a named rule with no settings is a pure shared breakpoint
73
+ * the app chrome can key its own presentation off — one definition serving
74
+ * both the layout math and the UI.
75
+ */
76
+ interface ResponsiveRule {
77
+ name?: string;
78
+ /** Declarative box query, or a predicate for anything the box can answer. */
79
+ when: BoxQuery | ((box: StageBox) => boolean);
80
+ /** The settings this situation asserts. Omit for a pure named query. */
81
+ settings?: StageSettingsPatch;
82
+ }
83
+ /**
84
+ * One axis of the arrival policy — stage-core's AlignValue ('start' |
85
+ * 'center' | 'end' | viewport fraction 0–1) plus one navigation-only word:
86
+ * 'keep' — this axis does not move on arrival: page forward, hold your
87
+ * pan (the two-column-paper feel; the PDF /XYZ null semantic).
88
+ */
89
+ type ArrivalAlignValue = AlignValue | 'keep';
90
+ interface ArrivalAlignment {
91
+ x: ArrivalAlignValue;
92
+ y: ArrivalAlignValue;
93
+ }
94
+ /**
95
+ * The stage's orthogonal settings, one view's own. Any subset changes in one
96
+ * `updateSettings()` call, and each value given replaces the current one
97
+ * whole. A preset is a {@link StageSettingsPatch} the app keeps and applies;
98
+ * no preset machinery lives here.
99
+ */
100
+ interface StageSettings {
101
+ /** Continuous scroll, or one item at a time. */
102
+ flow: FlowMode;
103
+ layout: LayoutKind;
104
+ spread: SpreadMode;
105
+ /** Page sizing: true PDF sizes, or equalize the cross axis so pages sit flush. */
106
+ sizing: SizingMode;
107
+ /** Grid column policy (grid layout only): 'square', 'auto' (wrapped), or a count. */
108
+ columns: GridColumns;
109
+ /** Clamp the camera to the content? Off = free infinite pan (construction drawings). */
110
+ bounded: boolean;
111
+ /**
112
+ * Breathing room (screen px) around the content — the one spacing concept.
113
+ * Fit-modes inset by it, arrivals leave it as a gutter, and the clamp lets the
114
+ * camera reveal exactly this much beyond each content edge.
115
+ */
116
+ padding: number;
117
+ /**
118
+ * Space between items — and between the halves of a spread. A number is world
119
+ * units (scales with zoom — the canvas feel); `{ px }` is screen px (UI-stable
120
+ * — the thumbnail feel). See {@link Gap}.
121
+ */
122
+ gap: Gap;
123
+ /**
124
+ * Reserved chrome real estate around each page, in screen px — one thickness
125
+ * per side. The page content is inset by these; the bands hold box-space
126
+ * chrome (a label below, a button row above, side rails) painted by the app
127
+ * via the adapter's `pageChrome` slot. Per page, not per item: in a spread
128
+ * every page keeps its own flanks. Constant screen px (unaffected by zoom).
129
+ *
130
+ * Naming rule for this settings bag: every setting describes the stage itself
131
+ * (the container) — `padding`, `gap`, `layout`, … The rare setting owned by the
132
+ * page carries the `page` prefix (`pageFrame`; `pageWidth` in zoom).
133
+ */
134
+ pageFrame: PageFrame;
135
+ /**
136
+ * Reading direction. RTL: horizontal items advance leftward, spreads bind on the
137
+ * right, grid rows fill right→left, and alignment 'start' on x means the right
138
+ * edge (logical, CSS-style). Navigation is index-based and never changes.
139
+ */
140
+ direction: Direction;
141
+ /**
142
+ * The alignment family — every camera move is defined by what it holds
143
+ * fixed. Gestures (pan/pinch/wheel) hold the pointer: physics, no setting.
144
+ * Explicit arrivals (positioned reveal, destinations, viewpoints) hold
145
+ * whatever the call specifies. These four settings govern the rest:
146
+ *
147
+ * fitAlign — the standing constraint: where content rests on an axis
148
+ * the camera cannot travel (it fits the true bounds — the
149
+ * scene in continuous flow, the item slice in paged). The
150
+ * clamp enforces it on every camera write — which is why a
151
+ * fitting axis settles identically whatever arrivalAlign
152
+ * says. center/center = document feel; y:'start' = sidebar
153
+ * thumbnails hugging the top.
154
+ * arrivalAlign — the landing policy: where navigation (goToPage,
155
+ * nextPage, previousPage, resetView) puts the target — the
156
+ * same at every zoom.
157
+ * start/start = reading (top-left, direction-aware);
158
+ * center/center = presentation/drawings (Drawboard feel);
159
+ * y: 0.35 = the find-bar line; 'keep' = don't move an axis.
160
+ * zoomAlign — the focal point of a pointer-less zoom (zoomIn/zoomOut,
161
+ * zoomTo, fit-mode switches). Pinch/ctrl+wheel always hold
162
+ * the pointer instead — that is physics, not policy.
163
+ * center/center = the view inflates around its middle;
164
+ * y:'start' = the first visible line holds still.
165
+ * anchorAlign — the viewport point that survives a reframe (viewport
166
+ * resize, page rotation, spread/gap change): the view
167
+ * anchor is captured there and restored there. start/start
168
+ * = the browser scroll model (growth reveals below — a
169
+ * container that mounts small and expands never shoves the
170
+ * document down); center/center = canvas-style symmetric
171
+ * resizes (the Figma feel).
172
+ *
173
+ * Named x values are logical (CSS-style: 'start' = reading start — the
174
+ * right edge in RTL); fractions are physical, like screen coordinates.
175
+ */
176
+ fitAlign: Alignment;
177
+ /** See {@link StageSettings.fitAlign} — where navigation lands, per axis. */
178
+ arrivalAlign: ArrivalAlignment;
179
+ /** See {@link StageSettings.fitAlign} — the pointer-less zoom focal point. */
180
+ zoomAlign: AlignmentValue;
181
+ /** See {@link StageSettings.fitAlign} — the viewport point reframes hold. */
182
+ anchorAlign: AlignmentValue;
183
+ /**
184
+ * A non-persistent view rotation: a quarter-turn (clockwise) applied to how
185
+ * every page is displayed in this lens, on top of each page's own /Rotate —
186
+ * Adobe's "Rotate View". A display setting like `zoom` or `layout`: per lens
187
+ * (the main viewer can rotate while a thumbnail lens stays upright), never
188
+ * written to the document, gone when the lens resets. The permanent
189
+ * counterpart — writing /Rotate into the PDF — is plugin-page-edit's
190
+ * `rotateBy`/`setRotation`.
191
+ */
192
+ viewRotation: PageRotation;
193
+ /** Zoom intent: a fit-mode (automatic/fit-page/fit-width/fit-all) or a fixed level. */
194
+ zoom: ZoomSpec;
195
+ /** Default behavior for goToPage, nextPage and previousPage. */
196
+ scrollBehavior: ScrollBehaviorKind;
197
+ /**
198
+ * Whether this view's pointer input reaches the interaction hub: a drag
199
+ * selects text or draws with the active tool, and the `pan` tool pans.
200
+ * Off, the view only scrolls (its own drag-to-pan), which suits a
201
+ * thumbnail strip. Without the interaction plugin the view only scrolls
202
+ * either way.
203
+ */
204
+ interaction: boolean;
205
+ /**
206
+ * With `interaction`: a drag in the space between pages pans whatever the
207
+ * tool, with a grab cursor there; there is nothing to select or draw off a
208
+ * page.
209
+ */
210
+ panFallback: boolean;
211
+ /**
212
+ * Whether a pinch, Ctrl+wheel (Cmd on a Mac) or a trackpad pinch zooms this
213
+ * view. Off, a zoom wheel scrolls instead, for a view with a fixed
214
+ * magnification; a pinch never zooms the browser page either way.
215
+ */
216
+ zoomGestures: boolean;
217
+ /**
218
+ * View pixels per PDF point — the platform's physical unit factor, folded into
219
+ * the layout so 100% (zoom 1) is physically accurate. Web = 96/72 (1 pt = 1/72",
220
+ * 1 CSS px = 1/96"); a native platform injects its own (iOS pt, Android dp). It
221
+ * scales every page's world size (and thus `contentScale`), so the camera math,
222
+ * `gap`/`padding`/`pageFrame` (world units), and absolute-px zoom modes
223
+ * (`pageWidth`) are all unaffected — only the pages themselves resize.
224
+ */
225
+ viewUnitsPerPoint: number;
226
+ }
227
+ /**
228
+ * A change to the settings: any of them, each replacing the current value
229
+ * whole. A `pageFrame` names only the sides it reserves (`{ bottom: 20 }`);
230
+ * the sides it leaves out are 0.
231
+ */
232
+ interface StageSettingsPatch extends Partial<Omit<StageSettings, 'pageFrame'>> {
233
+ pageFrame?: Partial<PageFrame>;
234
+ }
235
+ /**
236
+ * A laid-out page handed to the shell.
237
+ * - PageBox + `ref`: layout truth (world coords + identity) — the shell uses
238
+ * `x/y/width/height` only to position the page container.
239
+ * - `transform`: presentation truth — the single bridge between PDF points,
240
+ * view px, and device px for this page. Plugins do all coordinate work
241
+ * through it (`pageToView` / `viewToPage` / `deviceWidth` / `cssMatrix`),
242
+ * never by re-deriving `x * scale` / `* dpr`. Page-local, so it's
243
+ * camera/pan-invariant.
244
+ */
245
+ interface VisiblePage extends PageBox {
246
+ ref: PageRef;
247
+ /**
248
+ * The page's display-box (footprint) top-left in screen px, camera-resolved and
249
+ * snapped to the device grid. The shell positions the page container at this —
250
+ * snapping here (not in the adapter) keeps a CSS-rotated page on the pixel grid
251
+ * for every framework, with no hand-rounding.
252
+ */
253
+ screenX: number;
254
+ screenY: number;
255
+ transform: PageTransform;
256
+ /**
257
+ * The page region actually on screen, in un-rotated page points (y-down) —
258
+ * viewport ∩ footprint inverted through the transform (exact for
259
+ * quarter-turns). Zero-sized when the page sits outside the viewport.
260
+ * Visibility is the stage's data (it already intersects viewport × pages to
261
+ * virtualize); adapters and demand consumers (tiling's `PageViewDemand`)
262
+ * read it instead of re-deriving camera math per framework.
263
+ */
264
+ visibleRect: Rect;
265
+ }
266
+ /**
267
+ * A page-relative view memento: "what I'm looking at and how zoomed". The durable
268
+ * currency for per-page view memory (construction worksheets): capture with
269
+ * `getViewpoint()`, restore with `goToPage(page, { viewpoint })`. Survives resizes
270
+ * because the anchor is page-relative and fit-modes re-resolve.
271
+ */
272
+ interface Viewpoint {
273
+ anchor: Anchor;
274
+ zoom: ZoomSpec;
275
+ }
276
+ /** Durable, serializable view state — the unit of session persistence. */
277
+ interface StageViewState extends StageSettings {
278
+ cursor: number;
279
+ anchor: Anchor;
280
+ }
281
+ /**
282
+ * Options for the scroller writes — `Element.scrollTo` semantics: absolute
283
+ * offsets (screen px) into the current scroll range (see
284
+ * {@link StageHostCapability.getScrollMetrics}); an omitted axis does not move.
285
+ * `behavior` defaults to 'instant' (the DOM's 'auto'), not the stage's
286
+ * `scrollBehavior` setting — that setting governs navigation verbs, and a
287
+ * scrollbar thumb must track the pointer exactly.
288
+ */
289
+ interface StageScrollToOptions {
290
+ left?: number;
291
+ top?: number;
292
+ behavior?: ScrollBehaviorKind;
293
+ }
294
+ /** Options for `goToDestination`: the destination itself says where and how close. */
295
+ interface GoToDestinationOptions {
296
+ behavior?: ScrollBehaviorKind;
297
+ }
298
+ /** Options for navigation intents. */
299
+ interface GoToOptions {
300
+ behavior?: ScrollBehaviorKind;
301
+ /** Restore this exact viewpoint instead of fresh placement (per-page memory). */
302
+ viewpoint?: Viewpoint;
303
+ /** Override the landing for this navigation only (explicit beats default). */
304
+ arrivalAlign?: Partial<ArrivalAlignment>;
305
+ }
306
+ /**
307
+ * One axis of a reveal arrival — `scrollIntoView` vocabulary plus two
308
+ * PDF-protocol necessities:
309
+ * absent → minimal movement: scroll only if the target is off-screen
310
+ * (CSS 'nearest', as a bare reveal does)
311
+ * 'keep' → this axis does not move at all (PDF /XYZ null coordinate)
312
+ * 'start' → target edge at the viewport start (plus padding)
313
+ * 'center' → target centered
314
+ * 'end' → target edge at the viewport end (minus padding)
315
+ * number 0–1 → target center at this viewport fraction (0.35 = "top middle",
316
+ * the browser find-bar feel)
317
+ */
318
+ type RevealAnchorValue = 'keep' | 'start' | 'center' | 'end' | number;
319
+ interface RevealAnchor {
320
+ x?: RevealAnchorValue;
321
+ y?: RevealAnchorValue;
322
+ }
323
+ /**
324
+ * What happens to zoom on a reveal — always relative to the reveal's target
325
+ * rect (the whole page when no `rect` is given):
326
+ * 'keep' → pure pan, zoom untouched (search hits, /XYZ null zoom)
327
+ * { level } → explicit factor (/XYZ zoom)
328
+ * 'fit' → the rect fully visible (/FitR; /Fit, /FitB via rect=page/bbox)
329
+ * 'fit-width' → the rect's width fills the viewport (/FitH, /FitBH)
330
+ * 'fit-height' → the rect's height fills the viewport (/FitV, /FitBV)
331
+ */
332
+ type RevealZoom = 'keep' | 'fit' | 'fit-width' | 'fit-height' | {
333
+ level: number;
334
+ };
335
+ /**
336
+ * Options for `reveal`: bring a page or a spot on it into view (a search hit,
337
+ * "jump to comment"). A destination goes through `goToDestination`.
338
+ *
339
+ * With none of `rect`/`zoom`/`anchor` set, a reveal is minimal movement to
340
+ * make the page visible, with the cursor untouched.
341
+ * A positioned reveal (any of the three set) is "you are now looking at
342
+ * this spot": the camera places the target per the anchor, a zoom
343
+ * directive resolves to a concrete level (recorded as the zoom intent),
344
+ * and the cursor follows the camera — while still clamping against the
345
+ * normal camera bounds, so anchors are best-effort near document edges.
346
+ */
347
+ interface RevealOptions {
348
+ behavior?: ScrollBehaviorKind;
349
+ /**
350
+ * Target rect in page space (points from the page's top-left, y down; the
351
+ * space annotation, selection and search rects use).
352
+ * Absent or `null` → the whole page (null accepted so nullable sources flow
353
+ * in directly). A zero-size rect is a point.
354
+ */
355
+ rect?: Rect | null;
356
+ zoom?: RevealZoom;
357
+ anchor?: RevealAnchor;
358
+ }
359
+ interface StagePageChangedEvent {
360
+ /** The new current page, or null when the document has no pages. */
361
+ readonly page: PageRef | null;
362
+ readonly pageIndex: number;
363
+ readonly previousPageIndex: number;
364
+ }
365
+ interface StageZoomChangedEvent {
366
+ readonly level: number;
367
+ readonly previousLevel: number;
368
+ readonly mode: ZoomModeValue | 'custom';
369
+ }
370
+ interface StageCameraChangedEvent {
371
+ readonly camera: Camera;
372
+ }
373
+ interface StageMotionEndedEvent {
374
+ readonly camera: Camera;
375
+ }
376
+ interface StageSettingsChangedEvent {
377
+ readonly settings: StageSettings;
378
+ readonly changed: readonly (keyof StageSettings)[];
379
+ }
380
+ interface StageViewportChangedEvent {
381
+ readonly size: Size;
382
+ }
383
+ /** A viewport-space point or rect: this stage's container px, top-left origin. */
384
+ type ViewportPoint = Point;
385
+ type ViewportRect = Rect;
386
+ interface ZoomToOptions {
387
+ /** Hold this viewport point fixed while the level changes (default: the `zoomAlign` point). */
388
+ readonly around?: ViewportPoint;
389
+ }
390
+ /**
391
+ * The stage's public contract: the camera, layout, zoom and navigation of one
392
+ * presentation of a document. Pointer and surface plumbing (viewport size,
393
+ * gesture brackets, fling, world space, initial placement) live on the host
394
+ * contract (`@embedpdf/plugin-stage/contract/host`).
395
+ */
396
+ interface StageCapability {
397
+ /** Camera origin (world units) and zoom. */
398
+ getCamera(): Camera;
399
+ /** Write the camera directly; marks the cause as user motion. */
400
+ setCamera(camera: Camera): void;
401
+ /** The container size the stage was told about. */
402
+ getViewportSize(): Size;
403
+ /** Resolved zoom factor. */
404
+ getZoomLevel(): number;
405
+ /** The active zoom intent: a fit mode, or 'custom' for a fixed level. */
406
+ getZoomMode(): ZoomModeValue | 'custom';
407
+ /** The lens's view rotation — see {@link StageSettings.viewRotation}. */
408
+ getViewRotation(): PageRotation;
409
+ /** The current page's ref, or null before the document has pages. */
410
+ getCurrentPage(): PageRef | null;
411
+ /** The current page's display index, from 0. */
412
+ getCurrentPageIndex(): number;
413
+ /** How many pages the document has. */
414
+ getPageCount(): number;
415
+ /** Pages of the current item (one page, or a spread / grid row). */
416
+ listCurrentItemPages(): readonly PageInfo[];
417
+ /** Pages on screen, with their viewport rects and visible page-space rect. Reference-stable. */
418
+ listVisiblePages(): readonly VisiblePage[];
419
+ /** Is any part of the page (its ref or its index) on screen. False for a page that isn't in the document. */
420
+ isPageVisible(page: PageRef | number): boolean;
421
+ /** What the viewer is looking at plus the zoom intent, for per-page view memory. */
422
+ getViewpoint(): Viewpoint;
423
+ /**
424
+ * Where the view is, as a destination: the first page on screen, the point
425
+ * of it at the viewport's top-left corner, and no zoom, so following it
426
+ * keeps the reader's zoom. What `goToDestination` takes, and what a new
427
+ * outline item goes to. `null` before a page is on screen.
428
+ */
429
+ getCurrentDestination(): PageDestination | null;
430
+ /** Serialisable view state — the unit of session persistence. */
431
+ getViewState(): StageViewState;
432
+ /** Restore a saved view state; the responsive rules re-assert on top of its settings. */
433
+ applyViewState(view: StageViewState): void;
434
+ /** A tween or fling is running. */
435
+ isMoving(): boolean;
436
+ /** Halt any running tween or fling where it is. */
437
+ stopMotion(): void;
438
+ /** Set a fixed level (a bare number) or a fit mode. */
439
+ zoomTo(zoom: number | ZoomSpec, options?: ZoomToOptions): void;
440
+ /** Multiply the zoom, holding a viewport point fixed (default: the `zoomAlign` point). */
441
+ zoomBy(factor: number, options?: ZoomToOptions): void;
442
+ /** Zoom in one step around the `zoomAlign` point. */
443
+ zoomIn(): void;
444
+ /** Zoom out one step around the `zoomAlign` point. */
445
+ zoomOut(): void;
446
+ /** Zoom so the page width fills the viewport. */
447
+ fitWidth(): void;
448
+ /** Zoom so the whole page fits the viewport. */
449
+ fitPage(): void;
450
+ /** Fit the whole scene (every page) in view. */
451
+ fitAll(): void;
452
+ /** Fit width but never upscale past 100% (Adobe's "Automatic"). */
453
+ fitAutomatic(): void;
454
+ /**
455
+ * Go to a page: its `PageRef`, or its display index (0 is the first page; an
456
+ * index past either end goes to that end). The page lands by the arrival
457
+ * rule; pass `viewpoint` to restore a saved spot instead.
458
+ */
459
+ goToPage(page: PageRef | number, options?: GoToOptions): void;
460
+ /**
461
+ * Go where a destination says: a link's, an outline entry's, an action's,
462
+ * the document's open destination, or one you build. It may change the
463
+ * zoom, as the destination asks. A destination another PDF tool read, in
464
+ * the file's numbers, converts first:
465
+ * `goToDestination(pageDestinationOf(destination, layout.pdfCropBox))`.
466
+ */
467
+ goToDestination(destination: PageDestination, options?: GoToDestinationOptions): void;
468
+ goToFirstPage(options?: GoToOptions): void;
469
+ goToLastPage(options?: GoToOptions): void;
470
+ /** Step forward / backward by the navigation unit (the item if it fits the viewport, else the page). */
471
+ nextPage(options?: GoToOptions): void;
472
+ previousPage(options?: GoToOptions): void;
473
+ /** The cursor is before the last page. */
474
+ canGoNext(): boolean;
475
+ /** The cursor is after the first page. */
476
+ canGoPrevious(): boolean;
477
+ /**
478
+ * Bring a page, or a spot on it, into view: its `PageRef` or its display
479
+ * index. Bare, it scrolls only when the page is off screen and leaves the
480
+ * current page alone. With `rect`, `zoom` or `anchor` it lands on that spot,
481
+ * and the current page follows.
482
+ */
483
+ reveal(page: PageRef | number, options?: RevealOptions): void;
484
+ /** `Element.scrollTo` / `scrollBy` for the camera, in viewport px. */
485
+ scrollTo(options: StageScrollToOptions): void;
486
+ scrollBy(options: StageScrollToOptions): void;
487
+ /** Pan by a viewport delta. */
488
+ panBy(dxViewport: number, dyViewport: number): void;
489
+ /** Back to the first page at the current zoom intent. */
490
+ resetView(): void;
491
+ /** Set the lens's view rotation (see {@link StageSettings.viewRotation}). */
492
+ setViewRotation(rotation: PageRotation): void;
493
+ /** Turn the view rotation a quarter clockwise (90) or counter-clockwise (-90). */
494
+ rotateViewBy(delta: 90 | -90): void;
495
+ /** Every live setting (build or save a preset). */
496
+ getSettings(): StageSettings;
497
+ /**
498
+ * Change any subset in one update that keeps the view on the same page.
499
+ * Each value replaces the current one whole; a matching responsive rule
500
+ * still wins on the settings it names. Fires `onSettingsChanged`.
501
+ */
502
+ updateSettings(changes: StageSettingsPatch): void;
503
+ /** Back to the settings the plugin was registered with. Fires `onSettingsChanged`. */
504
+ resetSettings(): void;
505
+ /** Replace the container-query rules (see {@link ResponsiveRule}). */
506
+ setResponsiveRules(rules: readonly ResponsiveRule[]): void;
507
+ /** Names of the responsive rules matching the current box, in source order. */
508
+ listActiveRules(): readonly string[];
509
+ /** Whether the named responsive rule matches the current box. */
510
+ matchesRule(name: string): boolean;
511
+ /** The page under a viewport point and the page-space point on it; null over a gap. */
512
+ getPageAt(point: ViewportPoint): {
513
+ ref: PageRef;
514
+ point: Point;
515
+ scale: number;
516
+ /** The hit page's total display rotation (document /Rotate + view rotation). */
517
+ rotation: PageRotation;
518
+ /** The hit page's zoom relative to its 100% baseline. */
519
+ zoom: number;
520
+ } | null;
521
+ /**
522
+ * Project a viewport point onto one page (its ref or its index), unclamped;
523
+ * null when the page is not on screen or not in the document.
524
+ */
525
+ viewportToPage(page: PageRef | number, point: ViewportPoint): Point | null;
526
+ /** A page-space point → this stage's viewport; null when the page is not laid out. */
527
+ pageToViewport(page: PageRef | number, point: Point): ViewportPoint | null;
528
+ /** A page-space rect → its viewport-space bounding box; null when the page is not laid out. */
529
+ pageRectToViewport(page: PageRef | number, rect: Rect): ViewportRect | null;
530
+ /** The laid-out box for a page (its ref or its index), on screen or not; null before placement. */
531
+ getPageFrame(page: PageRef | number): VisiblePage | null;
532
+ /** The cursor page changed. */
533
+ readonly onPageChanged: EventHook<StagePageChangedEvent>;
534
+ /** The camera's zoom level changed. */
535
+ readonly onZoomChanged: EventHook<StageZoomChangedEvent>;
536
+ /** Coalesced per camera write, not per frame. */
537
+ readonly onCameraChanged: EventHook<StageCameraChangedEvent>;
538
+ /** A tween or fling settled, or was stopped. */
539
+ readonly onMotionEnded: EventHook<StageMotionEndedEvent>;
540
+ /** One or more settings changed value; `changed` names them. */
541
+ readonly onSettingsChanged: EventHook<StageSettingsChangedEvent>;
542
+ /** The host reported a new viewport size. */
543
+ readonly onViewportChanged: EventHook<StageViewportChangedEvent>;
544
+ }
545
+ interface StageConfig extends StageSettingsPatch {
546
+ /**
547
+ * Container queries for the settings bag (see {@link ResponsiveRule}).
548
+ * Defaults to `DEFAULT_RESPONSIVE` (compact containers get the thin phone
549
+ * gutter); pass `[]` to opt out entirely.
550
+ */
551
+ responsive?: readonly ResponsiveRule[];
552
+ }
553
+ /**
554
+ * Options for registering a stage instance. The stage is a lens, not a
555
+ * singleton: a document may be viewed through several stages at once (the
556
+ * main view, a wrapped thumbnail sidebar, …), each with its own camera and
557
+ * settings. Register an additional lens with its own `id` and `token`:
558
+ *
559
+ * const ThumbsToken = createCapabilityToken<StageCapability>('stage-thumbs');
560
+ * plugins = [
561
+ * stagePlugin(), // main lens
562
+ * stagePlugin({ id: 'stage-thumbs', token: ThumbsToken,
563
+ * layout: 'grid', columns: 'auto', zoom: { level: 0.2 } }),
564
+ * ];
565
+ *
566
+ * State, capabilities and teardown are keyed by plugin id × document in the
567
+ * kernel, so lenses never share anything.
568
+ */
569
+ interface StagePluginOptions extends StageConfig {
570
+ id?: string;
571
+ token?: CapabilityToken<StageCapability>;
572
+ }
573
+ //#endregion
574
+ export { StageCapability as A, StageViewportChangedEvent as B, ScrollBehaviorKind as C, SpreadMode$1 as D, SizingMode$1 as E, StageScrollToOptions as F, VisiblePage as G, Viewpoint as H, StageSettings as I, ZoomSpec$1 as J, ZoomMode as K, StageSettingsChangedEvent as L, StageMotionEndedEvent as M, StagePageChangedEvent as N, StageBox as O, StagePluginOptions as P, StageSettingsPatch as R, RevealZoom as S, Size$1 as T, ViewportPoint as U, StageZoomChangedEvent as V, ViewportRect as W, StageToken as X, ZoomToOptions as Y, Point$1 as _, ArrivalAlignValue as a, RevealAnchorValue as b, Camera$1 as c, Gap as d, GoToDestinationOptions as f, PageFrame$1 as g, LayoutKind as h, AlignmentValue$1 as i, StageConfig as j, StageCameraChangedEvent as k, Direction$1 as l, GridColumns as m, AlignValue$1 as n, ArrivalAlignment as o, GoToOptions as p, ZoomModeValue$1 as q, Alignment$1 as r, BoxQuery as s, Align as t, FlowMode as u, ResponsiveRule as v, ScrollMetrics as w, RevealOptions as x, RevealAnchor as y, StageViewState as z };
575
+ //# sourceMappingURL=contract-B3QLVDlb.d.cts.map
@@ -0,0 +1,11 @@
1
+ import { createCapabilityToken } from "@embedpdf/core";
2
+ import { ZoomMode as ZoomMode$1 } from "@embedpdf/core-stage";
3
+ //#region src/token.ts
4
+ /** The package token, created once here; `contract.ts` re-exports it and
5
+ * `host-contract.ts` widens it to the host capability. Additional lenses
6
+ * create their own token (see `StagePluginOptions`). */
7
+ const StageToken = createCapabilityToken("stage", { hint: `add stagePlugin() from '@embedpdf/plugin-stage' to your plugins list` });
8
+ //#endregion
9
+ export { StageToken as n, ZoomMode$1 as t };
10
+
11
+ //# sourceMappingURL=contract-BoOt8rJM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-BoOt8rJM.js","names":[],"sources":["../src/token.ts"],"sourcesContent":["/** The package token, created once here; `contract.ts` re-exports it and\n * `host-contract.ts` widens it to the host capability. Additional lenses\n * create their own token (see `StagePluginOptions`). */\nimport { createCapabilityToken } from '@embedpdf/core';\n\nimport type { StageCapability } from './contract';\n\nexport const StageToken = createCapabilityToken<StageCapability>('stage', {\n hint: `add stagePlugin() from '@embedpdf/plugin-stage' to your plugins list`,\n});\n"],"mappings":";;;;;;AAOA,MAAa,aAAa,sBAAuC,SAAS,EACxE,MAAM,uEACR,CAAC"}