@papyrus-sdk/ui-react-native 0.2.23 → 0.2.26

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
@@ -98,7 +98,9 @@ Performance tuning props are available on `Viewer` and `RightSheet`:
98
98
 
99
99
  - `virtualWindowSize` (`Viewer`): FlatList window size. Default: `8`.
100
100
  - `maxToRenderPerBatch` (`Viewer`): max items per render batch. Default: `6`.
101
- - `removeClippedSubviews` (`Viewer`): detach offscreen rows. Default: `true`.
101
+ - `removeClippedSubviews` (`Viewer`): detach offscreen rows. Default: `false`
102
+ for Android `viewerMode="compat"` and `true` otherwise. An explicit value is
103
+ always respected.
102
104
  - `thumbsInitialCount` (`RightSheet`): initial thumbnails rendered when opening pages tab. Default: `4`.
103
105
 
104
106
  Recommended starting points:
@@ -41,6 +41,85 @@ var resolvePinchGestureZoom = (startZoom, scaleFactor, bounds = DEFAULT_PINCH_ZO
41
41
  bounds.minZoom,
42
42
  bounds.maxZoom
43
43
  );
44
+ var createPinchInteraction = ({
45
+ committedZoom,
46
+ focalX,
47
+ focalY,
48
+ startScrollX,
49
+ startScrollY
50
+ }) => {
51
+ const safeZoom = clamp(
52
+ Number.isFinite(committedZoom) && committedZoom > 0 ? committedZoom : 1,
53
+ DEFAULT_PINCH_ZOOM_BOUNDS.minZoom,
54
+ DEFAULT_PINCH_ZOOM_BOUNDS.maxZoom
55
+ );
56
+ return {
57
+ committedZoom: safeZoom,
58
+ previewZoom: safeZoom,
59
+ focalPoint: {
60
+ x: Number.isFinite(focalX) ? focalX : 0,
61
+ y: Number.isFinite(focalY) ? focalY : 0
62
+ },
63
+ startScrollX: Number.isFinite(startScrollX) ? startScrollX : 0,
64
+ startScrollY: Number.isFinite(startScrollY) ? startScrollY : 0,
65
+ commitCount: 0,
66
+ outcome: "active"
67
+ };
68
+ };
69
+ var updatePinchInteraction = (state, previewZoom, bounds = DEFAULT_PINCH_ZOOM_BOUNDS) => {
70
+ if (state.outcome !== "active") return state;
71
+ return {
72
+ ...state,
73
+ previewZoom: clamp(
74
+ Number.isFinite(previewZoom) && previewZoom > 0 ? previewZoom : state.committedZoom,
75
+ bounds.minZoom,
76
+ bounds.maxZoom
77
+ )
78
+ };
79
+ };
80
+ var finishPinchInteraction = (state, action) => {
81
+ if (state.outcome !== "active") return state;
82
+ if (action === "cancel") {
83
+ return {
84
+ ...state,
85
+ previewZoom: state.committedZoom,
86
+ outcome: "cancel"
87
+ };
88
+ }
89
+ return {
90
+ ...state,
91
+ committedZoom: state.previewZoom,
92
+ commitCount: state.commitCount + 1,
93
+ outcome: "commit"
94
+ };
95
+ };
96
+ var createPinchController = ({
97
+ onPreview,
98
+ onCommit,
99
+ onCancel,
100
+ ...input
101
+ }) => {
102
+ let state = createPinchInteraction(input);
103
+ const update = (previewZoom, bounds = DEFAULT_PINCH_ZOOM_BOUNDS) => {
104
+ const next = updatePinchInteraction(state, previewZoom, bounds);
105
+ if (next === state) return;
106
+ state = next;
107
+ onPreview?.(state);
108
+ };
109
+ const finish = (action) => {
110
+ const next = finishPinchInteraction(state, action);
111
+ if (next === state) return;
112
+ state = next;
113
+ if (state.outcome === "cancel") onCancel?.(state);
114
+ else onCommit?.(state);
115
+ };
116
+ return {
117
+ update,
118
+ end: () => finish("end"),
119
+ cancel: () => finish("cancel"),
120
+ finalize: () => finish("finalize")
121
+ };
122
+ };
44
123
  var resolveAnchoredViewportOffset = ({
45
124
  viewportOffset,
46
125
  startScrollOffset,
@@ -166,6 +245,10 @@ export {
166
245
  resolvePinchPreviewScale,
167
246
  sanitizePinchPreviewScale,
168
247
  resolvePinchGestureZoom,
248
+ createPinchInteraction,
249
+ updatePinchInteraction,
250
+ finishPinchInteraction,
251
+ createPinchController,
169
252
  resolveAnchoredViewportOffset,
170
253
  resolveAnchoredDocumentOffset,
171
254
  resolveClampedScrollOffset,
@@ -175,4 +258,4 @@ export {
175
258
  resolveCenteredContentInset,
176
259
  shouldSuppressPressAfterPinch
177
260
  };
178
- //# sourceMappingURL=chunk-B36LWZCX.mjs.map
261
+ //# sourceMappingURL=chunk-K2ZLYLHR.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../gesture/pinchZoom.ts"],"sourcesContent":["export type PinchTouchPoint = {\n pageX: number;\n pageY: number;\n};\n\nexport type PinchSession = {\n initialDistance: number;\n initialZoom: number;\n};\n\nexport type PinchZoomBounds = {\n minZoom: number;\n maxZoom: number;\n};\n\nexport type PinchInteractionState = {\n committedZoom: number;\n previewZoom: number;\n focalPoint: { x: number; y: number };\n startScrollX: number;\n startScrollY: number;\n commitCount: number;\n outcome: \"active\" | \"commit\" | \"cancel\";\n};\n\nexport type PinchInteractionInput = {\n committedZoom: number;\n focalX: number;\n focalY: number;\n startScrollX: number;\n startScrollY: number;\n};\n\nexport type PinchControllerInput = PinchInteractionInput & {\n onPreview?: (state: PinchInteractionState) => void;\n onCommit?: (state: PinchInteractionState) => void;\n onCancel?: (state: PinchInteractionState) => void;\n};\n\nexport type PinchController = {\n update: (previewZoom: number, bounds?: PinchZoomBounds) => void;\n end: () => void;\n cancel: () => void;\n finalize: () => void;\n};\n\nexport type AnchoredViewportOffsetInput = {\n viewportOffset: number;\n startScrollOffset: number;\n startItemOffset: number;\n startItemLength: number;\n endItemOffset: number;\n endItemLength: number;\n viewportLength: number;\n endContentLength: number;\n};\n\nexport type AnchoredDocumentOffsetInput = {\n viewportOffset: number;\n startScrollOffset: number;\n startContentLength: number;\n endContentLength: number;\n viewportLength: number;\n};\n\nexport type DocumentSurfaceWidthInput = {\n viewportWidth: number;\n contentWidth: number;\n horizontalPadding: number;\n};\n\nexport type GlobalHorizontalOffsetInput = {\n offsetX: number;\n surfaceWidth: number;\n viewportWidth: number;\n};\n\nexport type AnchoredHorizontalSurfaceOffsetInput = {\n focalViewportX: number;\n startSurfaceScrollX: number;\n startSurfaceWidth: number;\n endSurfaceWidth: number;\n viewportWidth: number;\n};\n\nexport type CenteredContentInsetInput = {\n viewportLength: number;\n contentLength: number;\n};\n\nexport const DEFAULT_PINCH_ZOOM_BOUNDS: PinchZoomBounds = {\n minZoom: 0.5,\n maxZoom: 4,\n};\nexport const PINCH_PRESS_SUPPRESSION_MS = 120;\n\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(max, Math.max(min, value));\n\nexport const getTouchDistance = (touches: PinchTouchPoint[]): number => {\n if (touches.length < 2) return 0;\n const [first, second] = touches;\n return Math.hypot(second.pageX - first.pageX, second.pageY - first.pageY);\n};\n\nexport const isPinchTouchList = (touches: PinchTouchPoint[]): boolean =>\n touches.length === 2 && getTouchDistance(touches) > 0;\n\nexport const createPinchSession = (\n touches: PinchTouchPoint[],\n zoom: number,\n bounds: PinchZoomBounds = DEFAULT_PINCH_ZOOM_BOUNDS\n): PinchSession => ({\n initialDistance: Math.max(1, getTouchDistance(touches)),\n initialZoom: clamp(zoom, bounds.minZoom, bounds.maxZoom),\n});\n\nexport const resolvePinchZoomChange = (\n session: PinchSession,\n touches: PinchTouchPoint[],\n bounds: PinchZoomBounds = DEFAULT_PINCH_ZOOM_BOUNDS\n): number => {\n const distance = getTouchDistance(touches);\n if (distance <= 0) {\n return clamp(session.initialZoom, bounds.minZoom, bounds.maxZoom);\n }\n\n return clamp(\n session.initialZoom * (distance / session.initialDistance),\n bounds.minZoom,\n bounds.maxZoom\n );\n};\n\nexport const resolvePinchPreviewScale = (\n startZoom: number,\n previewZoom: number\n): number => {\n const safeStartZoom = Math.max(0.0001, Math.abs(startZoom));\n return previewZoom / safeStartZoom;\n};\n\nexport const sanitizePinchPreviewScale = (value: number): number => {\n if (!Number.isFinite(value) || value <= 0) {\n return 1;\n }\n return value;\n};\n\nexport const resolvePinchGestureZoom = (\n startZoom: number,\n scaleFactor: number,\n bounds: PinchZoomBounds = DEFAULT_PINCH_ZOOM_BOUNDS\n): number =>\n clamp(\n (Number.isFinite(startZoom) && startZoom > 0 ? startZoom : 1) *\n (Number.isFinite(scaleFactor) && scaleFactor > 0 ? scaleFactor : 1),\n bounds.minZoom,\n bounds.maxZoom\n );\n\nexport const createPinchInteraction = ({\n committedZoom,\n focalX,\n focalY,\n startScrollX,\n startScrollY,\n}: PinchInteractionInput): PinchInteractionState => {\n const safeZoom = clamp(\n Number.isFinite(committedZoom) && committedZoom > 0 ? committedZoom : 1,\n DEFAULT_PINCH_ZOOM_BOUNDS.minZoom,\n DEFAULT_PINCH_ZOOM_BOUNDS.maxZoom\n );\n\n return {\n committedZoom: safeZoom,\n previewZoom: safeZoom,\n focalPoint: {\n x: Number.isFinite(focalX) ? focalX : 0,\n y: Number.isFinite(focalY) ? focalY : 0,\n },\n startScrollX: Number.isFinite(startScrollX) ? startScrollX : 0,\n startScrollY: Number.isFinite(startScrollY) ? startScrollY : 0,\n commitCount: 0,\n outcome: \"active\",\n };\n};\n\nexport const updatePinchInteraction = (\n state: PinchInteractionState,\n previewZoom: number,\n bounds: PinchZoomBounds = DEFAULT_PINCH_ZOOM_BOUNDS\n): PinchInteractionState => {\n if (state.outcome !== \"active\") return state;\n return {\n ...state,\n previewZoom: clamp(\n Number.isFinite(previewZoom) && previewZoom > 0\n ? previewZoom\n : state.committedZoom,\n bounds.minZoom,\n bounds.maxZoom\n ),\n };\n};\n\nexport const finishPinchInteraction = (\n state: PinchInteractionState,\n action: \"end\" | \"finalize\" | \"cancel\"\n): PinchInteractionState => {\n if (state.outcome !== \"active\") return state;\n if (action === \"cancel\") {\n return {\n ...state,\n previewZoom: state.committedZoom,\n outcome: \"cancel\",\n };\n }\n\n return {\n ...state,\n committedZoom: state.previewZoom,\n commitCount: state.commitCount + 1,\n outcome: \"commit\",\n };\n};\n\nexport const createPinchController = ({\n onPreview,\n onCommit,\n onCancel,\n ...input\n}: PinchControllerInput): PinchController => {\n let state = createPinchInteraction(input);\n\n const update = (\n previewZoom: number,\n bounds: PinchZoomBounds = DEFAULT_PINCH_ZOOM_BOUNDS\n ) => {\n const next = updatePinchInteraction(state, previewZoom, bounds);\n if (next === state) return;\n state = next;\n onPreview?.(state);\n };\n\n const finish = (action: \"end\" | \"finalize\" | \"cancel\") => {\n const next = finishPinchInteraction(state, action);\n if (next === state) return;\n state = next;\n if (state.outcome === \"cancel\") onCancel?.(state);\n else onCommit?.(state);\n };\n\n return {\n update,\n end: () => finish(\"end\"),\n cancel: () => finish(\"cancel\"),\n finalize: () => finish(\"finalize\"),\n };\n};\n\nexport const resolveAnchoredViewportOffset = ({\n viewportOffset,\n startScrollOffset,\n startItemOffset,\n startItemLength,\n endItemOffset,\n endItemLength,\n viewportLength,\n endContentLength,\n}: AnchoredViewportOffsetInput): number => {\n const safeViewportOffset = Number.isFinite(viewportOffset)\n ? viewportOffset\n : 0;\n const safeStartScrollOffset = Number.isFinite(startScrollOffset)\n ? startScrollOffset\n : 0;\n const safeStartItemOffset = Number.isFinite(startItemOffset)\n ? startItemOffset\n : 0;\n const safeStartItemLength =\n Number.isFinite(startItemLength) && startItemLength > 0\n ? startItemLength\n : 1;\n const safeEndItemOffset = Number.isFinite(endItemOffset) ? endItemOffset : 0;\n const safeEndItemLength =\n Number.isFinite(endItemLength) && endItemLength > 0 ? endItemLength : 1;\n const safeViewportLength =\n Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;\n const safeEndContentLength =\n Number.isFinite(endContentLength) && endContentLength > 0\n ? endContentLength\n : safeEndItemOffset + safeEndItemLength;\n\n const contentPoint =\n safeStartScrollOffset + safeViewportOffset - safeStartItemOffset;\n const normalizedPoint = clamp(contentPoint / safeStartItemLength, 0, 1);\n const anchoredContentPoint =\n safeEndItemOffset + normalizedPoint * safeEndItemLength;\n return clamp(\n anchoredContentPoint - safeViewportOffset,\n 0,\n Math.max(0, safeEndContentLength - safeViewportLength)\n );\n};\n\nexport const resolveAnchoredDocumentOffset = ({\n viewportOffset,\n startScrollOffset,\n startContentLength,\n endContentLength,\n viewportLength,\n}: AnchoredDocumentOffsetInput): number => {\n const safeViewportOffset = Number.isFinite(viewportOffset)\n ? viewportOffset\n : 0;\n const safeStartScrollOffset = Number.isFinite(startScrollOffset)\n ? startScrollOffset\n : 0;\n const safeStartContentLength =\n Number.isFinite(startContentLength) && startContentLength > 0\n ? startContentLength\n : 1;\n const safeEndContentLength =\n Number.isFinite(endContentLength) && endContentLength > 0\n ? endContentLength\n : 0;\n const safeViewportLength =\n Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;\n\n const anchoredRatio = clamp(\n (safeStartScrollOffset + safeViewportOffset) / safeStartContentLength,\n 0,\n 1\n );\n\n return resolveClampedScrollOffset(\n anchoredRatio * safeEndContentLength - safeViewportOffset,\n safeEndContentLength,\n safeViewportLength\n );\n};\n\nexport const resolveClampedScrollOffset = (\n offset: number,\n contentLength: number,\n viewportLength: number\n): number => {\n const safeOffset = Number.isFinite(offset) ? offset : 0;\n const safeContentLength =\n Number.isFinite(contentLength) && contentLength > 0 ? contentLength : 0;\n const safeViewportLength =\n Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;\n return clamp(\n safeOffset,\n 0,\n Math.max(0, safeContentLength - safeViewportLength)\n );\n};\n\nexport const resolveDocumentSurfaceWidth = ({\n viewportWidth,\n contentWidth,\n horizontalPadding,\n}: DocumentSurfaceWidthInput): number => {\n const safeViewportWidth =\n Number.isFinite(viewportWidth) && viewportWidth > 0 ? viewportWidth : 0;\n const safeContentWidth =\n Number.isFinite(contentWidth) && contentWidth > 0 ? contentWidth : 0;\n const safeHorizontalPadding =\n Number.isFinite(horizontalPadding) && horizontalPadding > 0\n ? horizontalPadding\n : 0;\n\n return Math.max(\n safeViewportWidth,\n safeContentWidth + safeHorizontalPadding * 2\n );\n};\n\nexport const resolveGlobalHorizontalOffset = ({\n offsetX,\n surfaceWidth,\n viewportWidth,\n}: GlobalHorizontalOffsetInput): number =>\n resolveClampedScrollOffset(offsetX, surfaceWidth, viewportWidth);\n\nexport const resolveAnchoredHorizontalSurfaceOffset = ({\n focalViewportX,\n startSurfaceScrollX,\n startSurfaceWidth,\n endSurfaceWidth,\n viewportWidth,\n}: AnchoredHorizontalSurfaceOffsetInput): number => {\n const safeFocalViewportX = Number.isFinite(focalViewportX)\n ? focalViewportX\n : 0;\n const safeStartSurfaceScrollX = Number.isFinite(startSurfaceScrollX)\n ? startSurfaceScrollX\n : 0;\n const safeStartSurfaceWidth =\n Number.isFinite(startSurfaceWidth) && startSurfaceWidth > 0\n ? startSurfaceWidth\n : 1;\n const safeEndSurfaceWidth =\n Number.isFinite(endSurfaceWidth) && endSurfaceWidth > 0\n ? endSurfaceWidth\n : 0;\n const safeViewportWidth =\n Number.isFinite(viewportWidth) && viewportWidth > 0 ? viewportWidth : 0;\n\n const anchoredRatio = clamp(\n (safeStartSurfaceScrollX + safeFocalViewportX) / safeStartSurfaceWidth,\n 0,\n 1\n );\n\n return resolveGlobalHorizontalOffset({\n offsetX: anchoredRatio * safeEndSurfaceWidth - safeFocalViewportX,\n surfaceWidth: safeEndSurfaceWidth,\n viewportWidth: safeViewportWidth,\n });\n};\n\nexport const resolveCenteredContentInset = ({\n viewportLength,\n contentLength,\n}: CenteredContentInsetInput): number => {\n const safeViewportLength =\n Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;\n const safeContentLength =\n Number.isFinite(contentLength) && contentLength > 0 ? contentLength : 0;\n return Math.max(0, (safeViewportLength - safeContentLength) / 2);\n};\n\nexport const shouldSuppressPressAfterPinch = (\n lastPinchEndedAt: number | null | undefined,\n now = Date.now(),\n windowMs = PINCH_PRESS_SUPPRESSION_MS\n): boolean => {\n if (typeof lastPinchEndedAt !== \"number\") return false;\n const elapsedMs = now - lastPinchEndedAt;\n return elapsedMs >= 0 && elapsedMs < windowMs;\n};\n"],"mappings":";AA0FO,IAAM,4BAA6C;AAAA,EACxD,SAAS;AAAA,EACT,SAAS;AACX;AACO,IAAM,6BAA6B;AAE1C,IAAM,QAAQ,CAAC,OAAe,KAAa,QACzC,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC;AAE7B,IAAM,mBAAmB,CAAC,YAAuC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5C;AAAA,EACA;AAAA,EACA;AACF,MACE,2BAA2B,SAAS,cAAc,aAAa;AAE1D,IAAM,yCAAyC,CAAC;AAAA,EACrD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAoD;AAClD,QAAM,qBAAqB,OAAO,SAAS,cAAc,IACrD,iBACA;AACJ,QAAM,0BAA0B,OAAO,SAAS,mBAAmB,IAC/D,sBACA;AACJ,QAAM,wBACJ,OAAO,SAAS,iBAAiB,KAAK,oBAAoB,IACtD,oBACA;AACN,QAAM,sBACJ,OAAO,SAAS,eAAe,KAAK,kBAAkB,IAClD,kBACA;AACN,QAAM,oBACJ,OAAO,SAAS,aAAa,KAAK,gBAAgB,IAAI,gBAAgB;AAExE,QAAM,gBAAgB;AAAA,KACnB,0BAA0B,sBAAsB;AAAA,IACjD;AAAA,IACA;AAAA,EACF;AAEA,SAAO,8BAA8B;AAAA,IACnC,SAAS,gBAAgB,sBAAsB;AAAA,IAC/C,cAAc;AAAA,IACd,eAAe;AAAA,EACjB,CAAC;AACH;AAEO,IAAM,8BAA8B,CAAC;AAAA,EAC1C;AAAA,EACA;AACF,MAAyC;AACvC,QAAM,qBACJ,OAAO,SAAS,cAAc,KAAK,iBAAiB,IAAI,iBAAiB;AAC3E,QAAM,oBACJ,OAAO,SAAS,aAAa,KAAK,gBAAgB,IAAI,gBAAgB;AACxE,SAAO,KAAK,IAAI,IAAI,qBAAqB,qBAAqB,CAAC;AACjE;AAEO,IAAM,gCAAgC,CAC3C,kBACA,MAAM,KAAK,IAAI,GACf,WAAW,+BACC;AACZ,MAAI,OAAO,qBAAqB,SAAU,QAAO;AACjD,QAAM,YAAY,MAAM;AACxB,SAAO,aAAa,KAAK,YAAY;AACvC;","names":[]}
@@ -10,6 +10,36 @@ type PinchZoomBounds = {
10
10
  minZoom: number;
11
11
  maxZoom: number;
12
12
  };
13
+ type PinchInteractionState = {
14
+ committedZoom: number;
15
+ previewZoom: number;
16
+ focalPoint: {
17
+ x: number;
18
+ y: number;
19
+ };
20
+ startScrollX: number;
21
+ startScrollY: number;
22
+ commitCount: number;
23
+ outcome: "active" | "commit" | "cancel";
24
+ };
25
+ type PinchInteractionInput = {
26
+ committedZoom: number;
27
+ focalX: number;
28
+ focalY: number;
29
+ startScrollX: number;
30
+ startScrollY: number;
31
+ };
32
+ type PinchControllerInput = PinchInteractionInput & {
33
+ onPreview?: (state: PinchInteractionState) => void;
34
+ onCommit?: (state: PinchInteractionState) => void;
35
+ onCancel?: (state: PinchInteractionState) => void;
36
+ };
37
+ type PinchController = {
38
+ update: (previewZoom: number, bounds?: PinchZoomBounds) => void;
39
+ end: () => void;
40
+ cancel: () => void;
41
+ finalize: () => void;
42
+ };
13
43
  type AnchoredViewportOffsetInput = {
14
44
  viewportOffset: number;
15
45
  startScrollOffset: number;
@@ -57,6 +87,10 @@ declare const resolvePinchZoomChange: (session: PinchSession, touches: PinchTouc
57
87
  declare const resolvePinchPreviewScale: (startZoom: number, previewZoom: number) => number;
58
88
  declare const sanitizePinchPreviewScale: (value: number) => number;
59
89
  declare const resolvePinchGestureZoom: (startZoom: number, scaleFactor: number, bounds?: PinchZoomBounds) => number;
90
+ declare const createPinchInteraction: ({ committedZoom, focalX, focalY, startScrollX, startScrollY, }: PinchInteractionInput) => PinchInteractionState;
91
+ declare const updatePinchInteraction: (state: PinchInteractionState, previewZoom: number, bounds?: PinchZoomBounds) => PinchInteractionState;
92
+ declare const finishPinchInteraction: (state: PinchInteractionState, action: "end" | "finalize" | "cancel") => PinchInteractionState;
93
+ declare const createPinchController: ({ onPreview, onCommit, onCancel, ...input }: PinchControllerInput) => PinchController;
60
94
  declare const resolveAnchoredViewportOffset: ({ viewportOffset, startScrollOffset, startItemOffset, startItemLength, endItemOffset, endItemLength, viewportLength, endContentLength, }: AnchoredViewportOffsetInput) => number;
61
95
  declare const resolveAnchoredDocumentOffset: ({ viewportOffset, startScrollOffset, startContentLength, endContentLength, viewportLength, }: AnchoredDocumentOffsetInput) => number;
62
96
  declare const resolveClampedScrollOffset: (offset: number, contentLength: number, viewportLength: number) => number;
@@ -66,4 +100,4 @@ declare const resolveAnchoredHorizontalSurfaceOffset: ({ focalViewportX, startSu
66
100
  declare const resolveCenteredContentInset: ({ viewportLength, contentLength, }: CenteredContentInsetInput) => number;
67
101
  declare const shouldSuppressPressAfterPinch: (lastPinchEndedAt: number | null | undefined, now?: number, windowMs?: number) => boolean;
68
102
 
69
- export { type AnchoredDocumentOffsetInput, type AnchoredHorizontalSurfaceOffsetInput, type AnchoredViewportOffsetInput, type CenteredContentInsetInput, DEFAULT_PINCH_ZOOM_BOUNDS, type DocumentSurfaceWidthInput, type GlobalHorizontalOffsetInput, PINCH_PRESS_SUPPRESSION_MS, type PinchSession, type PinchTouchPoint, type PinchZoomBounds, createPinchSession, getTouchDistance, isPinchTouchList, resolveAnchoredDocumentOffset, resolveAnchoredHorizontalSurfaceOffset, resolveAnchoredViewportOffset, resolveCenteredContentInset, resolveClampedScrollOffset, resolveDocumentSurfaceWidth, resolveGlobalHorizontalOffset, resolvePinchGestureZoom, resolvePinchPreviewScale, resolvePinchZoomChange, sanitizePinchPreviewScale, shouldSuppressPressAfterPinch };
103
+ export { type AnchoredDocumentOffsetInput, type AnchoredHorizontalSurfaceOffsetInput, type AnchoredViewportOffsetInput, type CenteredContentInsetInput, DEFAULT_PINCH_ZOOM_BOUNDS, type DocumentSurfaceWidthInput, type GlobalHorizontalOffsetInput, PINCH_PRESS_SUPPRESSION_MS, type PinchController, type PinchControllerInput, type PinchInteractionInput, type PinchInteractionState, type PinchSession, type PinchTouchPoint, type PinchZoomBounds, createPinchController, createPinchInteraction, createPinchSession, finishPinchInteraction, getTouchDistance, isPinchTouchList, resolveAnchoredDocumentOffset, resolveAnchoredHorizontalSurfaceOffset, resolveAnchoredViewportOffset, resolveCenteredContentInset, resolveClampedScrollOffset, resolveDocumentSurfaceWidth, resolveGlobalHorizontalOffset, resolvePinchGestureZoom, resolvePinchPreviewScale, resolvePinchZoomChange, sanitizePinchPreviewScale, shouldSuppressPressAfterPinch, updatePinchInteraction };
@@ -10,6 +10,36 @@ type PinchZoomBounds = {
10
10
  minZoom: number;
11
11
  maxZoom: number;
12
12
  };
13
+ type PinchInteractionState = {
14
+ committedZoom: number;
15
+ previewZoom: number;
16
+ focalPoint: {
17
+ x: number;
18
+ y: number;
19
+ };
20
+ startScrollX: number;
21
+ startScrollY: number;
22
+ commitCount: number;
23
+ outcome: "active" | "commit" | "cancel";
24
+ };
25
+ type PinchInteractionInput = {
26
+ committedZoom: number;
27
+ focalX: number;
28
+ focalY: number;
29
+ startScrollX: number;
30
+ startScrollY: number;
31
+ };
32
+ type PinchControllerInput = PinchInteractionInput & {
33
+ onPreview?: (state: PinchInteractionState) => void;
34
+ onCommit?: (state: PinchInteractionState) => void;
35
+ onCancel?: (state: PinchInteractionState) => void;
36
+ };
37
+ type PinchController = {
38
+ update: (previewZoom: number, bounds?: PinchZoomBounds) => void;
39
+ end: () => void;
40
+ cancel: () => void;
41
+ finalize: () => void;
42
+ };
13
43
  type AnchoredViewportOffsetInput = {
14
44
  viewportOffset: number;
15
45
  startScrollOffset: number;
@@ -57,6 +87,10 @@ declare const resolvePinchZoomChange: (session: PinchSession, touches: PinchTouc
57
87
  declare const resolvePinchPreviewScale: (startZoom: number, previewZoom: number) => number;
58
88
  declare const sanitizePinchPreviewScale: (value: number) => number;
59
89
  declare const resolvePinchGestureZoom: (startZoom: number, scaleFactor: number, bounds?: PinchZoomBounds) => number;
90
+ declare const createPinchInteraction: ({ committedZoom, focalX, focalY, startScrollX, startScrollY, }: PinchInteractionInput) => PinchInteractionState;
91
+ declare const updatePinchInteraction: (state: PinchInteractionState, previewZoom: number, bounds?: PinchZoomBounds) => PinchInteractionState;
92
+ declare const finishPinchInteraction: (state: PinchInteractionState, action: "end" | "finalize" | "cancel") => PinchInteractionState;
93
+ declare const createPinchController: ({ onPreview, onCommit, onCancel, ...input }: PinchControllerInput) => PinchController;
60
94
  declare const resolveAnchoredViewportOffset: ({ viewportOffset, startScrollOffset, startItemOffset, startItemLength, endItemOffset, endItemLength, viewportLength, endContentLength, }: AnchoredViewportOffsetInput) => number;
61
95
  declare const resolveAnchoredDocumentOffset: ({ viewportOffset, startScrollOffset, startContentLength, endContentLength, viewportLength, }: AnchoredDocumentOffsetInput) => number;
62
96
  declare const resolveClampedScrollOffset: (offset: number, contentLength: number, viewportLength: number) => number;
@@ -66,4 +100,4 @@ declare const resolveAnchoredHorizontalSurfaceOffset: ({ focalViewportX, startSu
66
100
  declare const resolveCenteredContentInset: ({ viewportLength, contentLength, }: CenteredContentInsetInput) => number;
67
101
  declare const shouldSuppressPressAfterPinch: (lastPinchEndedAt: number | null | undefined, now?: number, windowMs?: number) => boolean;
68
102
 
69
- export { type AnchoredDocumentOffsetInput, type AnchoredHorizontalSurfaceOffsetInput, type AnchoredViewportOffsetInput, type CenteredContentInsetInput, DEFAULT_PINCH_ZOOM_BOUNDS, type DocumentSurfaceWidthInput, type GlobalHorizontalOffsetInput, PINCH_PRESS_SUPPRESSION_MS, type PinchSession, type PinchTouchPoint, type PinchZoomBounds, createPinchSession, getTouchDistance, isPinchTouchList, resolveAnchoredDocumentOffset, resolveAnchoredHorizontalSurfaceOffset, resolveAnchoredViewportOffset, resolveCenteredContentInset, resolveClampedScrollOffset, resolveDocumentSurfaceWidth, resolveGlobalHorizontalOffset, resolvePinchGestureZoom, resolvePinchPreviewScale, resolvePinchZoomChange, sanitizePinchPreviewScale, shouldSuppressPressAfterPinch };
103
+ export { type AnchoredDocumentOffsetInput, type AnchoredHorizontalSurfaceOffsetInput, type AnchoredViewportOffsetInput, type CenteredContentInsetInput, DEFAULT_PINCH_ZOOM_BOUNDS, type DocumentSurfaceWidthInput, type GlobalHorizontalOffsetInput, PINCH_PRESS_SUPPRESSION_MS, type PinchController, type PinchControllerInput, type PinchInteractionInput, type PinchInteractionState, type PinchSession, type PinchTouchPoint, type PinchZoomBounds, createPinchController, createPinchInteraction, createPinchSession, finishPinchInteraction, getTouchDistance, isPinchTouchList, resolveAnchoredDocumentOffset, resolveAnchoredHorizontalSurfaceOffset, resolveAnchoredViewportOffset, resolveCenteredContentInset, resolveClampedScrollOffset, resolveDocumentSurfaceWidth, resolveGlobalHorizontalOffset, resolvePinchGestureZoom, resolvePinchPreviewScale, resolvePinchZoomChange, sanitizePinchPreviewScale, shouldSuppressPressAfterPinch, updatePinchInteraction };
@@ -21,7 +21,10 @@ var pinchZoom_exports = {};
21
21
  __export(pinchZoom_exports, {
22
22
  DEFAULT_PINCH_ZOOM_BOUNDS: () => DEFAULT_PINCH_ZOOM_BOUNDS,
23
23
  PINCH_PRESS_SUPPRESSION_MS: () => PINCH_PRESS_SUPPRESSION_MS,
24
+ createPinchController: () => createPinchController,
25
+ createPinchInteraction: () => createPinchInteraction,
24
26
  createPinchSession: () => createPinchSession,
27
+ finishPinchInteraction: () => finishPinchInteraction,
25
28
  getTouchDistance: () => getTouchDistance,
26
29
  isPinchTouchList: () => isPinchTouchList,
27
30
  resolveAnchoredDocumentOffset: () => resolveAnchoredDocumentOffset,
@@ -35,7 +38,8 @@ __export(pinchZoom_exports, {
35
38
  resolvePinchPreviewScale: () => resolvePinchPreviewScale,
36
39
  resolvePinchZoomChange: () => resolvePinchZoomChange,
37
40
  sanitizePinchPreviewScale: () => sanitizePinchPreviewScale,
38
- shouldSuppressPressAfterPinch: () => shouldSuppressPressAfterPinch
41
+ shouldSuppressPressAfterPinch: () => shouldSuppressPressAfterPinch,
42
+ updatePinchInteraction: () => updatePinchInteraction
39
43
  });
40
44
  module.exports = __toCommonJS(pinchZoom_exports);
41
45
  var DEFAULT_PINCH_ZOOM_BOUNDS = {
@@ -80,6 +84,85 @@ var resolvePinchGestureZoom = (startZoom, scaleFactor, bounds = DEFAULT_PINCH_ZO
80
84
  bounds.minZoom,
81
85
  bounds.maxZoom
82
86
  );
87
+ var createPinchInteraction = ({
88
+ committedZoom,
89
+ focalX,
90
+ focalY,
91
+ startScrollX,
92
+ startScrollY
93
+ }) => {
94
+ const safeZoom = clamp(
95
+ Number.isFinite(committedZoom) && committedZoom > 0 ? committedZoom : 1,
96
+ DEFAULT_PINCH_ZOOM_BOUNDS.minZoom,
97
+ DEFAULT_PINCH_ZOOM_BOUNDS.maxZoom
98
+ );
99
+ return {
100
+ committedZoom: safeZoom,
101
+ previewZoom: safeZoom,
102
+ focalPoint: {
103
+ x: Number.isFinite(focalX) ? focalX : 0,
104
+ y: Number.isFinite(focalY) ? focalY : 0
105
+ },
106
+ startScrollX: Number.isFinite(startScrollX) ? startScrollX : 0,
107
+ startScrollY: Number.isFinite(startScrollY) ? startScrollY : 0,
108
+ commitCount: 0,
109
+ outcome: "active"
110
+ };
111
+ };
112
+ var updatePinchInteraction = (state, previewZoom, bounds = DEFAULT_PINCH_ZOOM_BOUNDS) => {
113
+ if (state.outcome !== "active") return state;
114
+ return {
115
+ ...state,
116
+ previewZoom: clamp(
117
+ Number.isFinite(previewZoom) && previewZoom > 0 ? previewZoom : state.committedZoom,
118
+ bounds.minZoom,
119
+ bounds.maxZoom
120
+ )
121
+ };
122
+ };
123
+ var finishPinchInteraction = (state, action) => {
124
+ if (state.outcome !== "active") return state;
125
+ if (action === "cancel") {
126
+ return {
127
+ ...state,
128
+ previewZoom: state.committedZoom,
129
+ outcome: "cancel"
130
+ };
131
+ }
132
+ return {
133
+ ...state,
134
+ committedZoom: state.previewZoom,
135
+ commitCount: state.commitCount + 1,
136
+ outcome: "commit"
137
+ };
138
+ };
139
+ var createPinchController = ({
140
+ onPreview,
141
+ onCommit,
142
+ onCancel,
143
+ ...input
144
+ }) => {
145
+ let state = createPinchInteraction(input);
146
+ const update = (previewZoom, bounds = DEFAULT_PINCH_ZOOM_BOUNDS) => {
147
+ const next = updatePinchInteraction(state, previewZoom, bounds);
148
+ if (next === state) return;
149
+ state = next;
150
+ onPreview?.(state);
151
+ };
152
+ const finish = (action) => {
153
+ const next = finishPinchInteraction(state, action);
154
+ if (next === state) return;
155
+ state = next;
156
+ if (state.outcome === "cancel") onCancel?.(state);
157
+ else onCommit?.(state);
158
+ };
159
+ return {
160
+ update,
161
+ end: () => finish("end"),
162
+ cancel: () => finish("cancel"),
163
+ finalize: () => finish("finalize")
164
+ };
165
+ };
83
166
  var resolveAnchoredViewportOffset = ({
84
167
  viewportOffset,
85
168
  startScrollOffset,
@@ -198,7 +281,10 @@ var shouldSuppressPressAfterPinch = (lastPinchEndedAt, now = Date.now(), windowM
198
281
  0 && (module.exports = {
199
282
  DEFAULT_PINCH_ZOOM_BOUNDS,
200
283
  PINCH_PRESS_SUPPRESSION_MS,
284
+ createPinchController,
285
+ createPinchInteraction,
201
286
  createPinchSession,
287
+ finishPinchInteraction,
202
288
  getTouchDistance,
203
289
  isPinchTouchList,
204
290
  resolveAnchoredDocumentOffset,
@@ -212,6 +298,7 @@ var shouldSuppressPressAfterPinch = (lastPinchEndedAt, now = Date.now(), windowM
212
298
  resolvePinchPreviewScale,
213
299
  resolvePinchZoomChange,
214
300
  sanitizePinchPreviewScale,
215
- shouldSuppressPressAfterPinch
301
+ shouldSuppressPressAfterPinch,
302
+ updatePinchInteraction
216
303
  });
217
304
  //# sourceMappingURL=pinchZoom.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../gesture/pinchZoom.ts"],"sourcesContent":["export type PinchTouchPoint = {\n pageX: number;\n pageY: number;\n};\n\nexport type PinchSession = {\n initialDistance: number;\n initialZoom: number;\n};\n\nexport type PinchZoomBounds = {\n minZoom: number;\n maxZoom: number;\n};\n\nexport type AnchoredViewportOffsetInput = {\n viewportOffset: number;\n startScrollOffset: number;\n startItemOffset: number;\n startItemLength: number;\n endItemOffset: number;\n endItemLength: number;\n viewportLength: number;\n endContentLength: number;\n};\n\nexport type AnchoredDocumentOffsetInput = {\n viewportOffset: number;\n startScrollOffset: number;\n startContentLength: number;\n endContentLength: number;\n viewportLength: number;\n};\n\nexport type DocumentSurfaceWidthInput = {\n viewportWidth: number;\n contentWidth: number;\n horizontalPadding: number;\n};\n\nexport type GlobalHorizontalOffsetInput = {\n offsetX: number;\n surfaceWidth: number;\n viewportWidth: number;\n};\n\nexport type AnchoredHorizontalSurfaceOffsetInput = {\n focalViewportX: number;\n startSurfaceScrollX: number;\n startSurfaceWidth: number;\n endSurfaceWidth: number;\n viewportWidth: number;\n};\n\nexport type CenteredContentInsetInput = {\n viewportLength: number;\n contentLength: number;\n};\n\nexport const DEFAULT_PINCH_ZOOM_BOUNDS: PinchZoomBounds = {\n minZoom: 0.5,\n maxZoom: 4,\n};\nexport const PINCH_PRESS_SUPPRESSION_MS = 120;\n\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(max, Math.max(min, value));\n\nexport const getTouchDistance = (touches: PinchTouchPoint[]): number => {\n if (touches.length < 2) return 0;\n const [first, second] = touches;\n return Math.hypot(second.pageX - first.pageX, second.pageY - first.pageY);\n};\n\nexport const isPinchTouchList = (touches: PinchTouchPoint[]): boolean =>\n touches.length === 2 && getTouchDistance(touches) > 0;\n\nexport const createPinchSession = (\n touches: PinchTouchPoint[],\n zoom: number,\n bounds: PinchZoomBounds = DEFAULT_PINCH_ZOOM_BOUNDS\n): PinchSession => ({\n initialDistance: Math.max(1, getTouchDistance(touches)),\n initialZoom: clamp(zoom, bounds.minZoom, bounds.maxZoom),\n});\n\nexport const resolvePinchZoomChange = (\n session: PinchSession,\n touches: PinchTouchPoint[],\n bounds: PinchZoomBounds = DEFAULT_PINCH_ZOOM_BOUNDS\n): number => {\n const distance = getTouchDistance(touches);\n if (distance <= 0) {\n return clamp(session.initialZoom, bounds.minZoom, bounds.maxZoom);\n }\n\n return clamp(\n session.initialZoom * (distance / session.initialDistance),\n bounds.minZoom,\n bounds.maxZoom\n );\n};\n\nexport const resolvePinchPreviewScale = (\n startZoom: number,\n previewZoom: number\n): number => {\n const safeStartZoom = Math.max(0.0001, Math.abs(startZoom));\n return previewZoom / safeStartZoom;\n};\n\nexport const sanitizePinchPreviewScale = (value: number): number => {\n if (!Number.isFinite(value) || value <= 0) {\n return 1;\n }\n return value;\n};\n\nexport const resolvePinchGestureZoom = (\n startZoom: number,\n scaleFactor: number,\n bounds: PinchZoomBounds = DEFAULT_PINCH_ZOOM_BOUNDS\n): number =>\n clamp(\n (Number.isFinite(startZoom) && startZoom > 0 ? startZoom : 1) *\n (Number.isFinite(scaleFactor) && scaleFactor > 0 ? scaleFactor : 1),\n bounds.minZoom,\n bounds.maxZoom\n );\n\nexport const resolveAnchoredViewportOffset = ({\n viewportOffset,\n startScrollOffset,\n startItemOffset,\n startItemLength,\n endItemOffset,\n endItemLength,\n viewportLength,\n endContentLength,\n}: AnchoredViewportOffsetInput): number => {\n const safeViewportOffset = Number.isFinite(viewportOffset)\n ? viewportOffset\n : 0;\n const safeStartScrollOffset = Number.isFinite(startScrollOffset)\n ? startScrollOffset\n : 0;\n const safeStartItemOffset = Number.isFinite(startItemOffset)\n ? startItemOffset\n : 0;\n const safeStartItemLength =\n Number.isFinite(startItemLength) && startItemLength > 0\n ? startItemLength\n : 1;\n const safeEndItemOffset = Number.isFinite(endItemOffset) ? endItemOffset : 0;\n const safeEndItemLength =\n Number.isFinite(endItemLength) && endItemLength > 0 ? endItemLength : 1;\n const safeViewportLength =\n Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;\n const safeEndContentLength =\n Number.isFinite(endContentLength) && endContentLength > 0\n ? endContentLength\n : safeEndItemOffset + safeEndItemLength;\n\n const contentPoint =\n safeStartScrollOffset + safeViewportOffset - safeStartItemOffset;\n const normalizedPoint = clamp(contentPoint / safeStartItemLength, 0, 1);\n const anchoredContentPoint =\n safeEndItemOffset + normalizedPoint * safeEndItemLength;\n return clamp(\n anchoredContentPoint - safeViewportOffset,\n 0,\n Math.max(0, safeEndContentLength - safeViewportLength)\n );\n};\n\nexport const resolveAnchoredDocumentOffset = ({\n viewportOffset,\n startScrollOffset,\n startContentLength,\n endContentLength,\n viewportLength,\n}: AnchoredDocumentOffsetInput): number => {\n const safeViewportOffset = Number.isFinite(viewportOffset)\n ? viewportOffset\n : 0;\n const safeStartScrollOffset = Number.isFinite(startScrollOffset)\n ? startScrollOffset\n : 0;\n const safeStartContentLength =\n Number.isFinite(startContentLength) && startContentLength > 0\n ? startContentLength\n : 1;\n const safeEndContentLength =\n Number.isFinite(endContentLength) && endContentLength > 0\n ? endContentLength\n : 0;\n const safeViewportLength =\n Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;\n\n const anchoredRatio = clamp(\n (safeStartScrollOffset + safeViewportOffset) / safeStartContentLength,\n 0,\n 1\n );\n\n return resolveClampedScrollOffset(\n anchoredRatio * safeEndContentLength - safeViewportOffset,\n safeEndContentLength,\n safeViewportLength\n );\n};\n\nexport const resolveClampedScrollOffset = (\n offset: number,\n contentLength: number,\n viewportLength: number\n): number => {\n const safeOffset = Number.isFinite(offset) ? offset : 0;\n const safeContentLength =\n Number.isFinite(contentLength) && contentLength > 0 ? contentLength : 0;\n const safeViewportLength =\n Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;\n return clamp(\n safeOffset,\n 0,\n Math.max(0, safeContentLength - safeViewportLength)\n );\n};\n\nexport const resolveDocumentSurfaceWidth = ({\n viewportWidth,\n contentWidth,\n horizontalPadding,\n}: DocumentSurfaceWidthInput): number => {\n const safeViewportWidth =\n Number.isFinite(viewportWidth) && viewportWidth > 0 ? viewportWidth : 0;\n const safeContentWidth =\n Number.isFinite(contentWidth) && contentWidth > 0 ? contentWidth : 0;\n const safeHorizontalPadding =\n Number.isFinite(horizontalPadding) && horizontalPadding > 0\n ? horizontalPadding\n : 0;\n\n return Math.max(\n safeViewportWidth,\n safeContentWidth + safeHorizontalPadding * 2\n );\n};\n\nexport const resolveGlobalHorizontalOffset = ({\n offsetX,\n surfaceWidth,\n viewportWidth,\n}: GlobalHorizontalOffsetInput): number =>\n resolveClampedScrollOffset(offsetX, surfaceWidth, viewportWidth);\n\nexport const resolveAnchoredHorizontalSurfaceOffset = ({\n focalViewportX,\n startSurfaceScrollX,\n startSurfaceWidth,\n endSurfaceWidth,\n viewportWidth,\n}: AnchoredHorizontalSurfaceOffsetInput): number => {\n const safeFocalViewportX = Number.isFinite(focalViewportX)\n ? focalViewportX\n : 0;\n const safeStartSurfaceScrollX = Number.isFinite(startSurfaceScrollX)\n ? startSurfaceScrollX\n : 0;\n const safeStartSurfaceWidth =\n Number.isFinite(startSurfaceWidth) && startSurfaceWidth > 0\n ? startSurfaceWidth\n : 1;\n const safeEndSurfaceWidth =\n Number.isFinite(endSurfaceWidth) && endSurfaceWidth > 0\n ? endSurfaceWidth\n : 0;\n const safeViewportWidth =\n Number.isFinite(viewportWidth) && viewportWidth > 0 ? viewportWidth : 0;\n\n const anchoredRatio = clamp(\n (safeStartSurfaceScrollX + safeFocalViewportX) / safeStartSurfaceWidth,\n 0,\n 1\n );\n\n return resolveGlobalHorizontalOffset({\n offsetX: anchoredRatio * safeEndSurfaceWidth - safeFocalViewportX,\n surfaceWidth: safeEndSurfaceWidth,\n viewportWidth: safeViewportWidth,\n });\n};\n\nexport const resolveCenteredContentInset = ({\n viewportLength,\n contentLength,\n}: CenteredContentInsetInput): number => {\n const safeViewportLength =\n Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;\n const safeContentLength =\n Number.isFinite(contentLength) && contentLength > 0 ? contentLength : 0;\n return Math.max(0, (safeViewportLength - safeContentLength) / 2);\n};\n\nexport const shouldSuppressPressAfterPinch = (\n lastPinchEndedAt: number | null | undefined,\n now = Date.now(),\n windowMs = PINCH_PRESS_SUPPRESSION_MS\n): boolean => {\n if (typeof lastPinchEndedAt !== \"number\") return false;\n const elapsedMs = now - lastPinchEndedAt;\n return elapsedMs >= 0 && elapsedMs < windowMs;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2DO,IAAM,4BAA6C;AAAA,EACxD,SAAS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,IACtD,oBACA;AACN,QAAM,sBACJ,OAAO,SAAS,eAAe,KAAK,kBAAkB,IAClD,kBACA;AACN,QAAM,oBACJ,OAAO,SAAS,aAAa,KAAK,gBAAgB,IAAI,gBAAgB;AAExE,QAAM,gBAAgB;AAAA,KACnB,0BAA0B,sBAAsB;AAAA,IACjD;AAAA,IACA;AAAA,EACF;AAEA,SAAO,8BAA8B;AAAA,IACnC,SAAS,gBAAgB,sBAAsB;AAAA,IAC/C,cAAc;AAAA,IACd,eAAe;AAAA,EACjB,CAAC;AACH;AAEO,IAAM,8BAA8B,CAAC;AAAA,EAC1C;AAAA,EACA;AACF,MAAyC;AACvC,QAAM,qBACJ,OAAO,SAAS,cAAc,KAAK,iBAAiB,IAAI,iBAAiB;AAC3E,QAAM,oBACJ,OAAO,SAAS,aAAa,KAAK,gBAAgB,IAAI,gBAAgB;AACxE,SAAO,KAAK,IAAI,IAAI,qBAAqB,qBAAqB,CAAC;AACjE;AAEO,IAAM,gCAAgC,CAC3C,kBACA,MAAM,KAAK,IAAI,GACf,WAAW,+BACC;AACZ,MAAI,OAAO,qBAAqB,SAAU,QAAO;AACjD,QAAM,YAAY,MAAM;AACxB,SAAO,aAAa,KAAK,YAAY;AACvC;","names":[]}
1
+ {"version":3,"sources":["../../gesture/pinchZoom.ts"],"sourcesContent":["export type PinchTouchPoint = {\n pageX: number;\n pageY: number;\n};\n\nexport type PinchSession = {\n initialDistance: number;\n initialZoom: number;\n};\n\nexport type PinchZoomBounds = {\n minZoom: number;\n maxZoom: number;\n};\n\nexport type PinchInteractionState = {\n committedZoom: number;\n previewZoom: number;\n focalPoint: { x: number; y: number };\n startScrollX: number;\n startScrollY: number;\n commitCount: number;\n outcome: \"active\" | \"commit\" | \"cancel\";\n};\n\nexport type PinchInteractionInput = {\n committedZoom: number;\n focalX: number;\n focalY: number;\n startScrollX: number;\n startScrollY: number;\n};\n\nexport type PinchControllerInput = PinchInteractionInput & {\n onPreview?: (state: PinchInteractionState) => void;\n onCommit?: (state: PinchInteractionState) => void;\n onCancel?: (state: PinchInteractionState) => void;\n};\n\nexport type PinchController = {\n update: (previewZoom: number, bounds?: PinchZoomBounds) => void;\n end: () => void;\n cancel: () => void;\n finalize: () => void;\n};\n\nexport type AnchoredViewportOffsetInput = {\n viewportOffset: number;\n startScrollOffset: number;\n startItemOffset: number;\n startItemLength: number;\n endItemOffset: number;\n endItemLength: number;\n viewportLength: number;\n endContentLength: number;\n};\n\nexport type AnchoredDocumentOffsetInput = {\n viewportOffset: number;\n startScrollOffset: number;\n startContentLength: number;\n endContentLength: number;\n viewportLength: number;\n};\n\nexport type DocumentSurfaceWidthInput = {\n viewportWidth: number;\n contentWidth: number;\n horizontalPadding: number;\n};\n\nexport type GlobalHorizontalOffsetInput = {\n offsetX: number;\n surfaceWidth: number;\n viewportWidth: number;\n};\n\nexport type AnchoredHorizontalSurfaceOffsetInput = {\n focalViewportX: number;\n startSurfaceScrollX: number;\n startSurfaceWidth: number;\n endSurfaceWidth: number;\n viewportWidth: number;\n};\n\nexport type CenteredContentInsetInput = {\n viewportLength: number;\n contentLength: number;\n};\n\nexport const DEFAULT_PINCH_ZOOM_BOUNDS: PinchZoomBounds = {\n minZoom: 0.5,\n maxZoom: 4,\n};\nexport const PINCH_PRESS_SUPPRESSION_MS = 120;\n\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(max, Math.max(min, value));\n\nexport const getTouchDistance = (touches: PinchTouchPoint[]): number => {\n if (touches.length < 2) return 0;\n const [first, second] = touches;\n return Math.hypot(second.pageX - first.pageX, second.pageY - first.pageY);\n};\n\nexport const isPinchTouchList = (touches: PinchTouchPoint[]): boolean =>\n touches.length === 2 && getTouchDistance(touches) > 0;\n\nexport const createPinchSession = (\n touches: PinchTouchPoint[],\n zoom: number,\n bounds: PinchZoomBounds = DEFAULT_PINCH_ZOOM_BOUNDS\n): PinchSession => ({\n initialDistance: Math.max(1, getTouchDistance(touches)),\n initialZoom: clamp(zoom, bounds.minZoom, bounds.maxZoom),\n});\n\nexport const resolvePinchZoomChange = (\n session: PinchSession,\n touches: PinchTouchPoint[],\n bounds: PinchZoomBounds = DEFAULT_PINCH_ZOOM_BOUNDS\n): number => {\n const distance = getTouchDistance(touches);\n if (distance <= 0) {\n return clamp(session.initialZoom, bounds.minZoom, bounds.maxZoom);\n }\n\n return clamp(\n session.initialZoom * (distance / session.initialDistance),\n bounds.minZoom,\n bounds.maxZoom\n );\n};\n\nexport const resolvePinchPreviewScale = (\n startZoom: number,\n previewZoom: number\n): number => {\n const safeStartZoom = Math.max(0.0001, Math.abs(startZoom));\n return previewZoom / safeStartZoom;\n};\n\nexport const sanitizePinchPreviewScale = (value: number): number => {\n if (!Number.isFinite(value) || value <= 0) {\n return 1;\n }\n return value;\n};\n\nexport const resolvePinchGestureZoom = (\n startZoom: number,\n scaleFactor: number,\n bounds: PinchZoomBounds = DEFAULT_PINCH_ZOOM_BOUNDS\n): number =>\n clamp(\n (Number.isFinite(startZoom) && startZoom > 0 ? startZoom : 1) *\n (Number.isFinite(scaleFactor) && scaleFactor > 0 ? scaleFactor : 1),\n bounds.minZoom,\n bounds.maxZoom\n );\n\nexport const createPinchInteraction = ({\n committedZoom,\n focalX,\n focalY,\n startScrollX,\n startScrollY,\n}: PinchInteractionInput): PinchInteractionState => {\n const safeZoom = clamp(\n Number.isFinite(committedZoom) && committedZoom > 0 ? committedZoom : 1,\n DEFAULT_PINCH_ZOOM_BOUNDS.minZoom,\n DEFAULT_PINCH_ZOOM_BOUNDS.maxZoom\n );\n\n return {\n committedZoom: safeZoom,\n previewZoom: safeZoom,\n focalPoint: {\n x: Number.isFinite(focalX) ? focalX : 0,\n y: Number.isFinite(focalY) ? focalY : 0,\n },\n startScrollX: Number.isFinite(startScrollX) ? startScrollX : 0,\n startScrollY: Number.isFinite(startScrollY) ? startScrollY : 0,\n commitCount: 0,\n outcome: \"active\",\n };\n};\n\nexport const updatePinchInteraction = (\n state: PinchInteractionState,\n previewZoom: number,\n bounds: PinchZoomBounds = DEFAULT_PINCH_ZOOM_BOUNDS\n): PinchInteractionState => {\n if (state.outcome !== \"active\") return state;\n return {\n ...state,\n previewZoom: clamp(\n Number.isFinite(previewZoom) && previewZoom > 0\n ? previewZoom\n : state.committedZoom,\n bounds.minZoom,\n bounds.maxZoom\n ),\n };\n};\n\nexport const finishPinchInteraction = (\n state: PinchInteractionState,\n action: \"end\" | \"finalize\" | \"cancel\"\n): PinchInteractionState => {\n if (state.outcome !== \"active\") return state;\n if (action === \"cancel\") {\n return {\n ...state,\n previewZoom: state.committedZoom,\n outcome: \"cancel\",\n };\n }\n\n return {\n ...state,\n committedZoom: state.previewZoom,\n commitCount: state.commitCount + 1,\n outcome: \"commit\",\n };\n};\n\nexport const createPinchController = ({\n onPreview,\n onCommit,\n onCancel,\n ...input\n}: PinchControllerInput): PinchController => {\n let state = createPinchInteraction(input);\n\n const update = (\n previewZoom: number,\n bounds: PinchZoomBounds = DEFAULT_PINCH_ZOOM_BOUNDS\n ) => {\n const next = updatePinchInteraction(state, previewZoom, bounds);\n if (next === state) return;\n state = next;\n onPreview?.(state);\n };\n\n const finish = (action: \"end\" | \"finalize\" | \"cancel\") => {\n const next = finishPinchInteraction(state, action);\n if (next === state) return;\n state = next;\n if (state.outcome === \"cancel\") onCancel?.(state);\n else onCommit?.(state);\n };\n\n return {\n update,\n end: () => finish(\"end\"),\n cancel: () => finish(\"cancel\"),\n finalize: () => finish(\"finalize\"),\n };\n};\n\nexport const resolveAnchoredViewportOffset = ({\n viewportOffset,\n startScrollOffset,\n startItemOffset,\n startItemLength,\n endItemOffset,\n endItemLength,\n viewportLength,\n endContentLength,\n}: AnchoredViewportOffsetInput): number => {\n const safeViewportOffset = Number.isFinite(viewportOffset)\n ? viewportOffset\n : 0;\n const safeStartScrollOffset = Number.isFinite(startScrollOffset)\n ? startScrollOffset\n : 0;\n const safeStartItemOffset = Number.isFinite(startItemOffset)\n ? startItemOffset\n : 0;\n const safeStartItemLength =\n Number.isFinite(startItemLength) && startItemLength > 0\n ? startItemLength\n : 1;\n const safeEndItemOffset = Number.isFinite(endItemOffset) ? endItemOffset : 0;\n const safeEndItemLength =\n Number.isFinite(endItemLength) && endItemLength > 0 ? endItemLength : 1;\n const safeViewportLength =\n Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;\n const safeEndContentLength =\n Number.isFinite(endContentLength) && endContentLength > 0\n ? endContentLength\n : safeEndItemOffset + safeEndItemLength;\n\n const contentPoint =\n safeStartScrollOffset + safeViewportOffset - safeStartItemOffset;\n const normalizedPoint = clamp(contentPoint / safeStartItemLength, 0, 1);\n const anchoredContentPoint =\n safeEndItemOffset + normalizedPoint * safeEndItemLength;\n return clamp(\n anchoredContentPoint - safeViewportOffset,\n 0,\n Math.max(0, safeEndContentLength - safeViewportLength)\n );\n};\n\nexport const resolveAnchoredDocumentOffset = ({\n viewportOffset,\n startScrollOffset,\n startContentLength,\n endContentLength,\n viewportLength,\n}: AnchoredDocumentOffsetInput): number => {\n const safeViewportOffset = Number.isFinite(viewportOffset)\n ? viewportOffset\n : 0;\n const safeStartScrollOffset = Number.isFinite(startScrollOffset)\n ? startScrollOffset\n : 0;\n const safeStartContentLength =\n Number.isFinite(startContentLength) && startContentLength > 0\n ? startContentLength\n : 1;\n const safeEndContentLength =\n Number.isFinite(endContentLength) && endContentLength > 0\n ? endContentLength\n : 0;\n const safeViewportLength =\n Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;\n\n const anchoredRatio = clamp(\n (safeStartScrollOffset + safeViewportOffset) / safeStartContentLength,\n 0,\n 1\n );\n\n return resolveClampedScrollOffset(\n anchoredRatio * safeEndContentLength - safeViewportOffset,\n safeEndContentLength,\n safeViewportLength\n );\n};\n\nexport const resolveClampedScrollOffset = (\n offset: number,\n contentLength: number,\n viewportLength: number\n): number => {\n const safeOffset = Number.isFinite(offset) ? offset : 0;\n const safeContentLength =\n Number.isFinite(contentLength) && contentLength > 0 ? contentLength : 0;\n const safeViewportLength =\n Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;\n return clamp(\n safeOffset,\n 0,\n Math.max(0, safeContentLength - safeViewportLength)\n );\n};\n\nexport const resolveDocumentSurfaceWidth = ({\n viewportWidth,\n contentWidth,\n horizontalPadding,\n}: DocumentSurfaceWidthInput): number => {\n const safeViewportWidth =\n Number.isFinite(viewportWidth) && viewportWidth > 0 ? viewportWidth : 0;\n const safeContentWidth =\n Number.isFinite(contentWidth) && contentWidth > 0 ? contentWidth : 0;\n const safeHorizontalPadding =\n Number.isFinite(horizontalPadding) && horizontalPadding > 0\n ? horizontalPadding\n : 0;\n\n return Math.max(\n safeViewportWidth,\n safeContentWidth + safeHorizontalPadding * 2\n );\n};\n\nexport const resolveGlobalHorizontalOffset = ({\n offsetX,\n surfaceWidth,\n viewportWidth,\n}: GlobalHorizontalOffsetInput): number =>\n resolveClampedScrollOffset(offsetX, surfaceWidth, viewportWidth);\n\nexport const resolveAnchoredHorizontalSurfaceOffset = ({\n focalViewportX,\n startSurfaceScrollX,\n startSurfaceWidth,\n endSurfaceWidth,\n viewportWidth,\n}: AnchoredHorizontalSurfaceOffsetInput): number => {\n const safeFocalViewportX = Number.isFinite(focalViewportX)\n ? focalViewportX\n : 0;\n const safeStartSurfaceScrollX = Number.isFinite(startSurfaceScrollX)\n ? startSurfaceScrollX\n : 0;\n const safeStartSurfaceWidth =\n Number.isFinite(startSurfaceWidth) && startSurfaceWidth > 0\n ? startSurfaceWidth\n : 1;\n const safeEndSurfaceWidth =\n Number.isFinite(endSurfaceWidth) && endSurfaceWidth > 0\n ? endSurfaceWidth\n : 0;\n const safeViewportWidth =\n Number.isFinite(viewportWidth) && viewportWidth > 0 ? viewportWidth : 0;\n\n const anchoredRatio = clamp(\n (safeStartSurfaceScrollX + safeFocalViewportX) / safeStartSurfaceWidth,\n 0,\n 1\n );\n\n return resolveGlobalHorizontalOffset({\n offsetX: anchoredRatio * safeEndSurfaceWidth - safeFocalViewportX,\n surfaceWidth: safeEndSurfaceWidth,\n viewportWidth: safeViewportWidth,\n });\n};\n\nexport const resolveCenteredContentInset = ({\n viewportLength,\n contentLength,\n}: CenteredContentInsetInput): number => {\n const safeViewportLength =\n Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;\n const safeContentLength =\n Number.isFinite(contentLength) && contentLength > 0 ? contentLength : 0;\n return Math.max(0, (safeViewportLength - safeContentLength) / 2);\n};\n\nexport const shouldSuppressPressAfterPinch = (\n lastPinchEndedAt: number | null | undefined,\n now = Date.now(),\n windowMs = PINCH_PRESS_SUPPRESSION_MS\n): boolean => {\n if (typeof lastPinchEndedAt !== \"number\") return false;\n const elapsedMs = now - lastPinchEndedAt;\n return elapsedMs >= 0 && elapsedMs < windowMs;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0FO,IAAM,4BAA6C;AAAA,EACxD,SAAS;AAAA,EACT,SAAS;AACX;AACO,IAAM,6BAA6B;AAE1C,IAAM,QAAQ,CAAC,OAAe,KAAa,QACzC,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC;AAE7B,IAAM,mBAAmB,CAAC,YAAuC;AACtE,MAAI,QAAQ,SAAS,EAAG,QAAO;AAC/B,QAAM,CAAC,OAAO,MAAM,IAAI;AACxB,SAAO,KAAK,MAAM,OAAO,QAAQ,MAAM,OAAO,OAAO,QAAQ,MAAM,KAAK;AAC1E;AAEO,IAAM,mBAAmB,CAAC,YAC/B,QAAQ,WAAW,KAAK,iBAAiB,OAAO,IAAI;AAE/C,IAAM,qBAAqB,CAChC,SACA,MACA,SAA0B,+BACR;AAAA,EAClB,iBAAiB,KAAK,IAAI,GAAG,iBAAiB,OAAO,CAAC;AAAA,EACtD,aAAa,MAAM,MAAM,OAAO,SAAS,OAAO,OAAO;A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AAM,oBACJ,OAAO,SAAS,aAAa,KAAK,gBAAgB,IAAI,gBAAgB;AAExE,QAAM,gBAAgB;AAAA,KACnB,0BAA0B,sBAAsB;AAAA,IACjD;AAAA,IACA;AAAA,EACF;AAEA,SAAO,8BAA8B;AAAA,IACnC,SAAS,gBAAgB,sBAAsB;AAAA,IAC/C,cAAc;AAAA,IACd,eAAe;AAAA,EACjB,CAAC;AACH;AAEO,IAAM,8BAA8B,CAAC;AAAA,EAC1C;AAAA,EACA;AACF,MAAyC;AACvC,QAAM,qBACJ,OAAO,SAAS,cAAc,KAAK,iBAAiB,IAAI,iBAAiB;AAC3E,QAAM,oBACJ,OAAO,SAAS,aAAa,KAAK,gBAAgB,IAAI,gBAAgB;AACxE,SAAO,KAAK,IAAI,IAAI,qBAAqB,qBAAqB,CAAC;AACjE;AAEO,IAAM,gCAAgC,CAC3C,kBACA,MAAM,KAAK,IAAI,GACf,WAAW,+BACC;AACZ,MAAI,OAAO,qBAAqB,SAAU,QAAO;AACjD,QAAM,YAAY,MAAM;AACxB,SAAO,aAAa,KAAK,YAAY;AACvC;","names":[]}
@@ -1,7 +1,10 @@
1
1
  import {
2
2
  DEFAULT_PINCH_ZOOM_BOUNDS,
3
3
  PINCH_PRESS_SUPPRESSION_MS,
4
+ createPinchController,
5
+ createPinchInteraction,
4
6
  createPinchSession,
7
+ finishPinchInteraction,
5
8
  getTouchDistance,
6
9
  isPinchTouchList,
7
10
  resolveAnchoredDocumentOffset,
@@ -15,13 +18,17 @@ import {
15
18
  resolvePinchPreviewScale,
16
19
  resolvePinchZoomChange,
17
20
  sanitizePinchPreviewScale,
18
- shouldSuppressPressAfterPinch
19
- } from "../chunk-B36LWZCX.mjs";
21
+ shouldSuppressPressAfterPinch,
22
+ updatePinchInteraction
23
+ } from "../chunk-K2ZLYLHR.mjs";
20
24
  import "../chunk-ZD7AOCMD.mjs";
21
25
  export {
22
26
  DEFAULT_PINCH_ZOOM_BOUNDS,
23
27
  PINCH_PRESS_SUPPRESSION_MS,
28
+ createPinchController,
29
+ createPinchInteraction,
24
30
  createPinchSession,
31
+ finishPinchInteraction,
25
32
  getTouchDistance,
26
33
  isPinchTouchList,
27
34
  resolveAnchoredDocumentOffset,
@@ -35,6 +42,7 @@ export {
35
42
  resolvePinchPreviewScale,
36
43
  resolvePinchZoomChange,
37
44
  sanitizePinchPreviewScale,
38
- shouldSuppressPressAfterPinch
45
+ shouldSuppressPressAfterPinch,
46
+ updatePinchInteraction
39
47
  };
40
48
  //# sourceMappingURL=pinchZoom.mjs.map
package/dist/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
- import React from 'react';
1
+ import React, { PropsWithChildren } from 'react';
2
2
  import { DocumentEngine, PdfViewerMode, DocumentType, MobilePrimaryDestination, DocumentSource } from '@papyrus-sdk/types';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
4
  import { PapyrusPageViewProps } from '@papyrus-sdk/engine-native';
4
5
  import { StyleProp, ViewStyle } from 'react-native';
5
- import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
 
7
7
  interface ViewerProps {
8
8
  engine: DocumentEngine;
@@ -11,18 +11,36 @@ interface ViewerProps {
11
11
  removeClippedSubviews?: boolean;
12
12
  useDedicatedAndroidPdfViewer?: boolean;
13
13
  viewerMode?: PdfViewerMode;
14
- onTextSelected?: (payload: {
15
- text: string;
16
- pageIndex: number;
17
- }) => void;
18
- onDefineSelection?: (payload: {
19
- text: string;
20
- pageIndex: number;
21
- }) => void;
22
- selectionActionLabel?: string;
23
14
  }
24
15
  declare const Viewer: React.FC<ViewerProps>;
25
16
 
17
+ type PerfSessionContext = {
18
+ runId?: string;
19
+ sampleId?: string;
20
+ documentLoadId?: string;
21
+ fixture: string;
22
+ };
23
+ type PerfSession = {
24
+ enabled: boolean;
25
+ context: Readonly<PerfSessionContext>;
26
+ createId: (kind: string) => string;
27
+ emit: (name: string, payload?: Record<string, unknown>) => void;
28
+ };
29
+ type PerfSessionOptions = {
30
+ enabled: boolean;
31
+ context: PerfSessionContext;
32
+ now?: () => number;
33
+ sink?: (line: string) => void;
34
+ };
35
+ declare function createPerfSession({ enabled, context, now, sink }: PerfSessionOptions): PerfSession;
36
+ declare function createRunId(): string;
37
+
38
+ declare function MobilePerfProvider({ session, context, children }: PropsWithChildren<{
39
+ session?: PerfSession;
40
+ context?: PerfSessionContext;
41
+ }>): react_jsx_runtime.JSX.Element;
42
+ declare function useMobilePerf(): PerfSession;
43
+
26
44
  type PageViewComponentType = React.ComponentType<PapyrusPageViewProps & React.RefAttributes<any>>;
27
45
  interface PageRendererProps {
28
46
  engine: DocumentEngine;
@@ -35,18 +53,13 @@ interface PageRendererProps {
35
53
  horizontalPadding?: number;
36
54
  spacing?: number;
37
55
  onSelectionDragActiveChange?: (active: boolean) => void;
38
- onTextSelected?: (payload: {
39
- text: string;
40
- pageIndex: number;
41
- }) => void;
42
- onDefineSelection?: (payload: {
43
- text: string;
44
- pageIndex: number;
45
- }) => void;
46
- selectionActionLabel?: string;
56
+ onPageTap?: () => void;
47
57
  gestureScrollLockActive?: boolean;
48
58
  lastPinchEndedAt?: number | null;
49
59
  requestSelectionVerticalAutoscroll?: (absoluteY: number) => number;
60
+ onRenderReady?: (pageIndex: number, renderedZoom: number) => void;
61
+ surfaceId?: string;
62
+ gestureId?: string;
50
63
  }
51
64
  declare const _default: React.NamedExoticComponent<PageRendererProps>;
52
65
 
@@ -119,13 +132,8 @@ declare function ReadingShell({ engine, title, documentType, thumbsInitialCount,
119
132
 
120
133
  type DedicatedAndroidPdfViewerProps = {
121
134
  engine: DocumentEngine;
122
- onDefineSelection?: (payload: {
123
- text: string;
124
- pageIndex: number;
125
- }) => void;
126
- selectionActionLabel?: string;
127
135
  };
128
- declare function DedicatedAndroidPdfViewer({ engine, onDefineSelection, selectionActionLabel, }: DedicatedAndroidPdfViewerProps): react_jsx_runtime.JSX.Element;
136
+ declare function DedicatedAndroidPdfViewer({ engine, }: DedicatedAndroidPdfViewerProps): react_jsx_runtime.JSX.Element;
129
137
 
130
138
  type OverflowSheetProps = {
131
139
  visible: boolean;
@@ -186,6 +194,9 @@ declare const MOBILE_CHROME_METRICS: {
186
194
  readonly topbarPageButtonSize: 30;
187
195
  readonly bottomBarItemPaddingHorizontal: 5;
188
196
  readonly bottomBarItemPaddingVertical: 3;
197
+ readonly topbarHeight: 56;
198
+ readonly progressGap: 18;
199
+ readonly progressHorizontalOffset: 10;
189
200
  };
190
201
 
191
- export { AnnotationEditor, BottomBar, CoverPreview, DocumentActionsSheet, InfoSheet, MOBILE_CHROME_METRICS, DedicatedAndroidPdfViewer as NativePdfDocumentViewer, OverflowSheet, _default as PageRenderer, ProgressPill, ReadingShell, RightSheet, SearchOverlay, SearchResultsSheet, SettingsSheet, ToolDock, Topbar, Viewer };
202
+ export { AnnotationEditor, BottomBar, CoverPreview, DocumentActionsSheet, InfoSheet, MOBILE_CHROME_METRICS, MobilePerfProvider, DedicatedAndroidPdfViewer as NativePdfDocumentViewer, OverflowSheet, _default as PageRenderer, ProgressPill, ReadingShell, RightSheet, SearchOverlay, SearchResultsSheet, SettingsSheet, ToolDock, Topbar, Viewer, createPerfSession, createRunId, useMobilePerf };