@embedpdf/plugin-stage 3.0.0-next.14 → 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.
package/README.md CHANGED
@@ -15,7 +15,7 @@ move, and each one keeps exactly one thing still:
15
15
  | drag, pinch, ctrl+wheel | the content under your pointer | nothing — that's physics |
16
16
  | click zoom in/out, `zoomTo`, switch to fit-width | a focal point in the viewport | **`zoomAlign`** |
17
17
  | resize the container, rotate a page, change spread | the spot you were looking at | **`anchorAlign`** |
18
- | `goToPage`, next/prev, reset | nothing — a fresh landing | **`arrivalAlign`** |
18
+ | `goToPage`, `nextPage`/`previousPage`, `resetView` | nothing — a fresh landing | **`arrivalAlign`** |
19
19
  | click an outline entry, a search hit, a PDF link | whatever the call specifies | the call itself, per-`reveal` |
20
20
 
21
21
  One more setting stands outside the table. When an axis of content **fits** the
@@ -23,7 +23,8 @@ viewport, the camera has no freedom on that axis — there is nowhere to scroll.
23
23
  **`fitAlign`** says where content rests in that case (default: centered). It is a
24
24
  standing constraint applied to _every_ move above, not a move of its own.
25
25
 
26
- All four settings speak the same per-axis vocabulary, and `x`/`y` are independent:
26
+ All four settings speak the same per-axis vocabulary — `'start' | 'center' | 'end'`,
27
+ plus a viewport fraction for the three move policies — and `x`/`y` are independent:
27
28
 
28
29
  ```ts
29
30
  stagePlugin({
@@ -39,9 +40,9 @@ want, configure nothing.)
39
40
 
40
41
  ## `arrivalAlign` — where navigation lands
41
42
 
42
- When you _navigate_ (`goToPage`, `next`, `prev`, reset), the target page lands at
43
- the same place **at every zoom level** — landing is a policy, never a side effect
44
- of how zoomed in you happen to be. Per axis:
43
+ When you _navigate_ (`goToPage`, `nextPage`, `previousPage`, `resetView`), the
44
+ target page lands at the same place **at every zoom level** — landing is a
45
+ policy, never a side effect of how zoomed in you happen to be. Per axis:
45
46
 
46
47
  | Value | Landing |
47
48
  | ---------- | ------------------------------------------------------------------------- |
@@ -56,13 +57,13 @@ and last pages — exactly like a browser.
56
57
 
57
58
  One value deserves a second look: **`x: 'keep'`** — page forward without losing
58
59
  your horizontal position. Zoomed into the left column of a two-column paper,
59
- `next()` takes you to the left column of the next page. (It's the PDF
60
+ `nextPage()` takes you to the left column of the next page. (It's the PDF
60
61
  `/XYZ null` semantic, as a default.)
61
62
 
62
63
  Any single navigation can override the setting:
63
64
 
64
65
  ```ts
65
- stage.goToPage(12, { arrivalAlign: { y: 'center' } });
66
+ stage.goToPage(page, { arrivalAlign: { y: 'center' } });
66
67
  ```
67
68
 
68
69
  ## `zoomAlign` — what focal-less zoom zooms around
@@ -99,9 +100,9 @@ Adobe's "Rotate View": a quarter-turn applied to how **every page displays in
99
100
  this lens**, on top of each page's own `/Rotate`.
100
101
 
101
102
  ```ts
102
- stage.rotateView(90); // toolbar verb: one quarter-turn clockwise from here
103
+ stage.rotateViewBy(90); // toolbar verb: one quarter-turn clockwise from here
103
104
  stage.setViewRotation(180); // absolute
104
- stage.viewRotation(); // 0 | 90 | 180 | 270
105
+ stage.getViewRotation(); // 0 | 90 | 180 | 270
105
106
  stagePlugin({ viewRotation: 90 }); // or start rotated
106
107
  ```
107
108
 
@@ -146,26 +147,35 @@ stagePlugin({ arrivalAlign: { x: 'keep', y: 0.35 } });
146
147
  ```
147
148
 
148
149
  A "preset" is just an object you keep and pass — to `stagePlugin()` at setup or
149
- `stage.update()` at runtime. The plugin ships no named presets; that taxonomy
150
- belongs to your product.
150
+ `stage.updateSettings()` at runtime. The plugin ships no named presets; that
151
+ taxonomy belongs to your product.
151
152
 
152
153
  ## The scroller contract — scrollbars, minimaps, "% read"
153
154
 
154
- The Stage doubles as a **virtual scroll element**. `scrollMetrics()` projects
155
+ The Stage doubles as a **virtual scroll element**. `getScrollMetrics()` projects
155
156
  the camera into the native DOM vocabulary — every field means exactly what it
156
- means on a `<div>`, in screen px:
157
+ means on a `<div>`, in screen px. It lives on the host lens
158
+ (`@embedpdf/plugin-stage/contract/host`), the same runtime capability typed
159
+ wider, because a scrollbar is chrome that drives the camera:
157
160
 
158
161
  ```ts
159
- const m = stage.scrollMetrics();
160
- // m.scrollTop / m.scrollLeft — where you are
161
- // m.scrollHeight / m.scrollWidth — how much there is
162
- // m.clientHeight / m.clientWidth — how much you see
163
- // m.scrollableY / m.scrollableX — false = nothing to scroll (hide the bar)
162
+ import { StageToken } from '@embedpdf/plugin-stage/contract/host';
163
+
164
+ const stage = kernel.capability(StageToken);
165
+ const metrics = stage.getScrollMetrics();
166
+ // metrics.scrollTop / metrics.scrollLeft — where you are
167
+ // metrics.scrollHeight / metrics.scrollWidth — how much there is
168
+ // metrics.clientHeight / metrics.clientWidth — how much you see
169
+ // metrics.scrollableY / metrics.scrollableX — false = nothing to scroll (hide the bar)
164
170
 
165
171
  stage.scrollTo({ top: 0 }); // Element.scrollTo semantics
166
- stage.scrollBy({ top: m.clientHeight * 0.9 }); // page down
172
+ stage.scrollBy({ top: metrics.clientHeight * 0.9 }); // page down
167
173
  ```
168
174
 
175
+ In React, `useScrollMetrics()` reads the same numbers reactively and
176
+ `<Scrollbar axis="y" />` draws a native-feeling bar from them (both from
177
+ `@embedpdf/react/stage`).
178
+
169
179
  That is the whole contract. A scrollbar thumb is
170
180
  `clientHeight / scrollHeight` of the track, positioned at
171
181
  `scrollTop / scrollHeight`; a reading-progress indicator is
@@ -179,8 +189,8 @@ a scrollbar can never disagree with where panning actually stops:
179
189
  like a longer document.
180
190
  - **Paged flow** scrolls the current item: the bar reflects one page (or
181
191
  spread), and hides when it fits.
182
- - **A fitting axis** reports `scrollable: false` with `scrollWidth ===
183
- clientWidth` — the native "no bar" condition, for free.
192
+ - **A fitting axis** reports `scrollableX: false` (or `scrollableY`) with
193
+ `scrollWidth === clientWidth` — the native "no bar" condition, for free.
184
194
  - **RTL** stays physical: `scrollLeft` is the offset from the range's left
185
195
  edge, deliberately sidestepping the DOM's negative-`scrollLeft` behavior.
186
196
 
@@ -192,7 +202,7 @@ is in view, both axes report unscrollable and the bars disappear.
192
202
 
193
203
  `scrollTo`/`scrollBy` default to `behavior: 'instant'` (the DOM's `'auto'`);
194
204
  pass `'smooth'` for the camera tween. The `scrollBehavior` _setting_ is not
195
- consulted — it governs navigation verbs (`goToPage`, `next`), not scrolling.
205
+ consulted — it governs navigation verbs (`goToPage`, `nextPage`), not scrolling.
196
206
 
197
207
  ## What these settings never touch
198
208
 
@@ -201,5 +211,5 @@ consulted — it governs navigation verbs (`goToPage`, `next`), not scrolling.
201
211
  outline clicks, PDF destinations — carries its own anchor and always beats the
202
212
  settings. Bare `reveal(page)` stays minimal-movement: it scrolls only as far as
203
213
  needed to make the page visible, and not a pixel further.
204
- - **Saved viewpoints.** `goToPage(i, { viewpoint })` restores exactly what was
214
+ - **Saved viewpoints.** `goToPage(page, { viewpoint })` restores exactly what was
205
215
  captured.
@@ -0,0 +1,16 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_contract = require("../contract-iSNhoXLC.cjs");
3
+ let _embedpdf_core = require("@embedpdf/core");
4
+ let _embedpdf_core_stage = require("@embedpdf/core-stage");
5
+ //#region src/host-contract.ts
6
+ const StageToken = (0, _embedpdf_core.createHostToken)(require_contract.StageToken);
7
+ //#endregion
8
+ exports.StageToken = StageToken;
9
+ Object.defineProperty(exports, "ZoomMode", {
10
+ enumerable: true,
11
+ get: function() {
12
+ return _embedpdf_core_stage.ZoomMode;
13
+ }
14
+ });
15
+
16
+ //# sourceMappingURL=host.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.cjs","names":["PublicStageToken"],"sources":["../../src/host-contract.ts"],"sourcesContent":["import { createHostToken, type PageRef, type Unsubscribe } from '@embedpdf/core';\nimport type { Point, Rect } from '@embedpdf/core-geometry';\nimport type { Camera, ScrollMetrics, Size } from '@embedpdf/core-stage';\n\nimport type { StageCapability, StageViewState, ViewportPoint } from './contract';\nimport { StageToken as PublicStageToken } from './token';\n\nexport * from './contract';\nexport type { StageState } from './model';\n\n/**\n * The host lens: what the surface binding, the gesture controller and sibling\n * plugins need. The same runtime token as the public contract, typed wider.\n */\nexport interface StageHostCapability extends StageCapability {\n /**\n * Report the container box (ResizeObserver); the first real size triggers placement. After\n * that, a box with no area (hidden, or taken out of the page) keeps the last real viewport.\n */\n setViewportSize(size: Size): void;\n /** Report the device pixel ratio so page transforms render crisp. */\n setDevicePixelRatio(ratio: number): void;\n /** Bracket a direct-manipulation gesture (touch pan / pinch); `elastic` enables rubber-band. */\n beginGesture(options?: { elastic?: boolean }): void;\n endGesture(): void;\n /** Momentum pan from a release velocity in viewport px/s. */\n fling(velocityX: number, velocityY: number): void;\n /** The touch double-tap zoom ladder around a viewport point. */\n doubleTapZoom(point: ViewportPoint): void;\n /** Zoom by a factor holding a viewport point fixed — the pinch primitive. */\n zoomAround(point: ViewportPoint, factor: number): void;\n /** The camera as a native scroller, in viewport px. Reference-stable. */\n getScrollMetrics(): ScrollMetrics;\n worldToViewport(world: Point): ViewportPoint;\n viewportToWorld(point: ViewportPoint): Point;\n pageToWorld(page: PageRef, point: Point): Point | null;\n /** Offer a candidate initial view; the highest-priority non-null wins at placement. */\n provideInitialView(priority: number, provider: () => StageViewState | null): Unsubscribe;\n /** Resolve the registered providers once (else reset). Called when the viewport is ready. */\n placeInitial(): void;\n /** Re-resolve the zoom intent against the current scene (wired to the page registry). */\n refit(): void;\n /** This lens's identity — the stage plugin id; pointer samples are stamped with it. */\n getLensId(): string;\n}\n\nexport const StageToken = createHostToken<StageHostCapability>(PublicStageToken);\nexport type { Camera, Point, Rect, ScrollMetrics, Size };\n"],"mappings":";;;;;AA8CA,MAAa,cAAA,GAAA,eAAA,gBAAA,CAAkDA,iBAAAA,UAAgB"}
@@ -0,0 +1,3 @@
1
+ import { A as StageCapability, B as StageViewportChangedEvent, C as ScrollBehaviorKind, D as SpreadMode, E as SizingMode, F as StageScrollToOptions, G as VisiblePage, H as Viewpoint, I as StageSettings, J as ZoomSpec, K as ZoomMode, L as StageSettingsChangedEvent, M as StageMotionEndedEvent, N as StagePageChangedEvent, O as StageBox, P as StagePluginOptions, R as StageSettingsPatch, S as RevealZoom, U as ViewportPoint, V as StageZoomChangedEvent, W as ViewportRect, Y as ZoomToOptions, a as ArrivalAlignValue, b as RevealAnchorValue, d as Gap, f as GoToDestinationOptions, g as PageFrame, h as LayoutKind, i as AlignmentValue, j as StageConfig, k as StageCameraChangedEvent, l as Direction, m as GridColumns, n as AlignValue, o as ArrivalAlignment, p as GoToOptions, q as ZoomModeValue, r as Alignment, s as BoxQuery, t as Align, u as FlowMode, v as ResponsiveRule, x as RevealOptions, y as RevealAnchor, z as StageViewState } from "../contract-DZR_jRer.cjs";
2
+ import { a as Size, c as StageState, i as ScrollMetrics, n as Point, o as StageHostCapability, r as Rect, s as StageToken, t as Camera } from "../host-contract-CPtbnJ4j.cjs";
3
+ export { type Align, type AlignValue, type Alignment, type AlignmentValue, ArrivalAlignValue, ArrivalAlignment, BoxQuery, type Camera, type Direction, FlowMode, Gap, GoToDestinationOptions, GoToOptions, GridColumns, LayoutKind, type PageFrame, type Point, type Rect, ResponsiveRule, RevealAnchor, RevealAnchorValue, RevealOptions, RevealZoom, ScrollBehaviorKind, type ScrollMetrics, type Size, type SizingMode, type SpreadMode, StageBox, StageCameraChangedEvent, StageCapability, StageConfig, StageHostCapability, StageMotionEndedEvent, StagePageChangedEvent, StagePluginOptions, StageScrollToOptions, StageSettings, StageSettingsChangedEvent, StageSettingsPatch, type StageState, StageToken, StageViewState, StageViewportChangedEvent, StageZoomChangedEvent, Viewpoint, ViewportPoint, ViewportRect, VisiblePage, ZoomMode, type ZoomModeValue, type ZoomSpec, ZoomToOptions };
@@ -0,0 +1,3 @@
1
+ import { A as StageCapability, B as StageViewportChangedEvent, C as ScrollBehaviorKind, D as SpreadMode, E as SizingMode, F as StageScrollToOptions, G as VisiblePage, H as Viewpoint, I as StageSettings, J as ZoomSpec, K as ZoomMode, L as StageSettingsChangedEvent, M as StageMotionEndedEvent, N as StagePageChangedEvent, O as StageBox, P as StagePluginOptions, R as StageSettingsPatch, S as RevealZoom, U as ViewportPoint, V as StageZoomChangedEvent, W as ViewportRect, Y as ZoomToOptions, a as ArrivalAlignValue, b as RevealAnchorValue, d as Gap, f as GoToDestinationOptions, g as PageFrame, h as LayoutKind, i as AlignmentValue, j as StageConfig, k as StageCameraChangedEvent, l as Direction, m as GridColumns, n as AlignValue, o as ArrivalAlignment, p as GoToOptions, q as ZoomModeValue, r as Alignment, s as BoxQuery, t as Align, u as FlowMode, v as ResponsiveRule, x as RevealOptions, y as RevealAnchor, z as StageViewState } from "../contract-CjHtrfJj.js";
2
+ import { a as Size, c as StageState, i as ScrollMetrics, n as Point, o as StageHostCapability, r as Rect, s as StageToken, t as Camera } from "../host-contract-Du5tEZ4h.js";
3
+ export { type Align, type AlignValue, type Alignment, type AlignmentValue, ArrivalAlignValue, ArrivalAlignment, BoxQuery, type Camera, type Direction, FlowMode, Gap, GoToDestinationOptions, GoToOptions, GridColumns, LayoutKind, type PageFrame, type Point, type Rect, ResponsiveRule, RevealAnchor, RevealAnchorValue, RevealOptions, RevealZoom, ScrollBehaviorKind, type ScrollMetrics, type Size, type SizingMode, type SpreadMode, StageBox, StageCameraChangedEvent, StageCapability, StageConfig, StageHostCapability, StageMotionEndedEvent, StagePageChangedEvent, StagePluginOptions, StageScrollToOptions, StageSettings, StageSettingsChangedEvent, StageSettingsPatch, type StageState, StageToken, StageViewState, StageViewportChangedEvent, StageZoomChangedEvent, Viewpoint, ViewportPoint, ViewportRect, VisiblePage, ZoomMode, type ZoomModeValue, type ZoomSpec, ZoomToOptions };
@@ -0,0 +1,8 @@
1
+ import { n as StageToken$1, t as ZoomMode } from "../contract-BoOt8rJM.js";
2
+ import { createHostToken } from "@embedpdf/core";
3
+ //#region src/host-contract.ts
4
+ const StageToken = createHostToken(StageToken$1);
5
+ //#endregion
6
+ export { StageToken, ZoomMode };
7
+
8
+ //# sourceMappingURL=host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.js","names":["PublicStageToken"],"sources":["../../src/host-contract.ts"],"sourcesContent":["import { createHostToken, type PageRef, type Unsubscribe } from '@embedpdf/core';\nimport type { Point, Rect } from '@embedpdf/core-geometry';\nimport type { Camera, ScrollMetrics, Size } from '@embedpdf/core-stage';\n\nimport type { StageCapability, StageViewState, ViewportPoint } from './contract';\nimport { StageToken as PublicStageToken } from './token';\n\nexport * from './contract';\nexport type { StageState } from './model';\n\n/**\n * The host lens: what the surface binding, the gesture controller and sibling\n * plugins need. The same runtime token as the public contract, typed wider.\n */\nexport interface StageHostCapability extends StageCapability {\n /**\n * Report the container box (ResizeObserver); the first real size triggers placement. After\n * that, a box with no area (hidden, or taken out of the page) keeps the last real viewport.\n */\n setViewportSize(size: Size): void;\n /** Report the device pixel ratio so page transforms render crisp. */\n setDevicePixelRatio(ratio: number): void;\n /** Bracket a direct-manipulation gesture (touch pan / pinch); `elastic` enables rubber-band. */\n beginGesture(options?: { elastic?: boolean }): void;\n endGesture(): void;\n /** Momentum pan from a release velocity in viewport px/s. */\n fling(velocityX: number, velocityY: number): void;\n /** The touch double-tap zoom ladder around a viewport point. */\n doubleTapZoom(point: ViewportPoint): void;\n /** Zoom by a factor holding a viewport point fixed — the pinch primitive. */\n zoomAround(point: ViewportPoint, factor: number): void;\n /** The camera as a native scroller, in viewport px. Reference-stable. */\n getScrollMetrics(): ScrollMetrics;\n worldToViewport(world: Point): ViewportPoint;\n viewportToWorld(point: ViewportPoint): Point;\n pageToWorld(page: PageRef, point: Point): Point | null;\n /** Offer a candidate initial view; the highest-priority non-null wins at placement. */\n provideInitialView(priority: number, provider: () => StageViewState | null): Unsubscribe;\n /** Resolve the registered providers once (else reset). Called when the viewport is ready. */\n placeInitial(): void;\n /** Re-resolve the zoom intent against the current scene (wired to the page registry). */\n refit(): void;\n /** This lens's identity — the stage plugin id; pointer samples are stamped with it. */\n getLensId(): string;\n}\n\nexport const StageToken = createHostToken<StageHostCapability>(PublicStageToken);\nexport type { Camera, Point, Rect, ScrollMetrics, Size };\n"],"mappings":";;;AA8CA,MAAa,aAAa,gBAAqCA,YAAgB"}
@@ -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"}