@papyrus-sdk/ui-react-native 0.2.10 → 0.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Papyrus Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -5,10 +5,20 @@ React Native UI components for Papyrus viewers.
5
5
  ## Install
6
6
 
7
7
  ```bash
8
- npm install @papyrus-sdk/ui-react-native @papyrus-sdk/engine-native @papyrus-sdk/core @papyrus-sdk/types
8
+ npm install @papyrus-sdk/ui-react-native @papyrus-sdk/engine-native @papyrus-sdk/core @papyrus-sdk/types react-native-gesture-handler
9
9
  ```
10
10
 
11
- `@papyrus-sdk/core` and `@papyrus-sdk/types` are required peer dependencies.
11
+ `@papyrus-sdk/core`, `@papyrus-sdk/types`, and `react-native-gesture-handler` are required peer dependencies.
12
+
13
+ Wrap the app root with `GestureHandlerRootView` before rendering Papyrus components:
14
+
15
+ ```tsx
16
+ import { GestureHandlerRootView } from 'react-native-gesture-handler';
17
+
18
+ <GestureHandlerRootView style={{ flex: 1 }}>
19
+ <App />
20
+ </GestureHandlerRootView>
21
+ ```
12
22
 
13
23
  For EPUB/TXT previews on mobile:
14
24
 
@@ -0,0 +1,63 @@
1
+ // gesture/selectionInteraction.ts
2
+ var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
3
+ var DRAG_SELECTION_TOOLS = /* @__PURE__ */ new Set([
4
+ "highlight",
5
+ "underline",
6
+ "squiggly",
7
+ "strikeout"
8
+ ]);
9
+ var resolveAxisAutoscroll = (coordinate, size, threshold, maxStep) => {
10
+ if (size <= 0 || threshold <= 0 || maxStep <= 0) return 0;
11
+ const startDistance = clamp(coordinate, 0, size);
12
+ if (startDistance < threshold) {
13
+ const intensity = 1 - startDistance / threshold;
14
+ return -Math.round(maxStep * intensity);
15
+ }
16
+ const endDistance = clamp(size - coordinate, 0, size);
17
+ if (endDistance < threshold) {
18
+ const intensity = 1 - endDistance / threshold;
19
+ return Math.round(maxStep * intensity);
20
+ }
21
+ return 0;
22
+ };
23
+ var shouldEnableViewerScroll = ({
24
+ selectionDragActive,
25
+ gestureScrollLockActive = false
26
+ }) => !selectionDragActive && !gestureScrollLockActive;
27
+ var shouldEnableSelectionDrag = ({
28
+ activeTool,
29
+ interactionMode
30
+ }) => DRAG_SELECTION_TOOLS.has(activeTool) || activeTool === "select" && interactionMode === "select";
31
+ var isToolDockToolSelected = ({
32
+ activeTool,
33
+ interactionMode,
34
+ toolId
35
+ }) => toolId === "select" ? activeTool === "select" && interactionMode === "select" : activeTool === toolId;
36
+ var getToolDockDismissState = ({
37
+ activeTool,
38
+ interactionMode
39
+ }) => ({
40
+ toolDockOpen: false,
41
+ activeTool,
42
+ interactionMode: activeTool === "select" && interactionMode === "select" ? "pan" : interactionMode
43
+ });
44
+ var getSelectionEdgeAutoscroll = ({
45
+ x,
46
+ y,
47
+ width,
48
+ height,
49
+ threshold,
50
+ maxStep
51
+ }) => ({
52
+ dx: resolveAxisAutoscroll(x, width, threshold, maxStep),
53
+ dy: resolveAxisAutoscroll(y, height, threshold, maxStep)
54
+ });
55
+
56
+ export {
57
+ shouldEnableViewerScroll,
58
+ shouldEnableSelectionDrag,
59
+ isToolDockToolSelected,
60
+ getToolDockDismissState,
61
+ getSelectionEdgeAutoscroll
62
+ };
63
+ //# sourceMappingURL=chunk-GCVUTXFR.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../gesture/selectionInteraction.ts"],"sourcesContent":["export type ViewerScrollState = {\n selectionDragActive: boolean;\n gestureScrollLockActive?: boolean;\n};\n\nexport type SelectionGestureTool =\n | \"select\"\n | \"highlight\"\n | \"underline\"\n | \"squiggly\"\n | \"strikeout\"\n | \"text\"\n | \"comment\"\n | \"ink\";\n\nexport type SelectionInteractionMode = \"pan\" | \"select\";\n\nexport type SelectionGestureActivationInput = {\n activeTool: SelectionGestureTool;\n interactionMode: SelectionInteractionMode;\n};\n\nexport type ToolDockSelectionState = SelectionGestureActivationInput & {\n toolId: SelectionGestureTool;\n};\n\nexport type ToolDockDismissState = SelectionGestureActivationInput & {\n toolDockOpen: boolean;\n};\n\nexport type SelectionEdgeAutoscrollInput = {\n x: number;\n y: number;\n width: number;\n height: number;\n threshold: number;\n maxStep: number;\n};\n\nexport type SelectionEdgeAutoscroll = {\n dx: number;\n dy: number;\n};\n\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(max, Math.max(min, value));\n\nconst DRAG_SELECTION_TOOLS = new Set<SelectionGestureTool>([\n \"highlight\",\n \"underline\",\n \"squiggly\",\n \"strikeout\",\n]);\n\nconst resolveAxisAutoscroll = (\n coordinate: number,\n size: number,\n threshold: number,\n maxStep: number\n) => {\n if (size <= 0 || threshold <= 0 || maxStep <= 0) return 0;\n\n const startDistance = clamp(coordinate, 0, size);\n if (startDistance < threshold) {\n const intensity = 1 - startDistance / threshold;\n return -Math.round(maxStep * intensity);\n }\n\n const endDistance = clamp(size - coordinate, 0, size);\n if (endDistance < threshold) {\n const intensity = 1 - endDistance / threshold;\n return Math.round(maxStep * intensity);\n }\n\n return 0;\n};\n\nexport const shouldEnableViewerScroll = ({\n selectionDragActive,\n gestureScrollLockActive = false,\n}: ViewerScrollState) => !selectionDragActive && !gestureScrollLockActive;\n\nexport const shouldEnableSelectionDrag = ({\n activeTool,\n interactionMode,\n}: SelectionGestureActivationInput) =>\n DRAG_SELECTION_TOOLS.has(activeTool) ||\n (activeTool === \"select\" && interactionMode === \"select\");\n\nexport const isToolDockToolSelected = ({\n activeTool,\n interactionMode,\n toolId,\n}: ToolDockSelectionState) =>\n toolId === \"select\"\n ? activeTool === \"select\" && interactionMode === \"select\"\n : activeTool === toolId;\n\nexport const getToolDockDismissState = ({\n activeTool,\n interactionMode,\n}: SelectionGestureActivationInput): ToolDockDismissState => ({\n toolDockOpen: false,\n activeTool,\n interactionMode:\n activeTool === \"select\" && interactionMode === \"select\"\n ? \"pan\"\n : interactionMode,\n});\n\nexport const getSelectionEdgeAutoscroll = ({\n x,\n y,\n width,\n height,\n threshold,\n maxStep,\n}: SelectionEdgeAutoscrollInput): SelectionEdgeAutoscroll => ({\n dx: resolveAxisAutoscroll(x, width, threshold, maxStep),\n dy: resolveAxisAutoscroll(y, height, threshold, maxStep),\n});\n"],"mappings":";AA4CA,IAAM,QAAQ,CAAC,OAAe,KAAa,QACzC,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC;AAEpC,IAAM,uBAAuB,oBAAI,IAA0B;AAAA,EACzD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,wBAAwB,CAC5B,YACA,MACA,WACA,YACG;AACH,MAAI,QAAQ,KAAK,aAAa,KAAK,WAAW,EAAG,QAAO;AAExD,QAAM,gBAAgB,MAAM,YAAY,GAAG,IAAI;AAC/C,MAAI,gBAAgB,WAAW;AAC7B,UAAM,YAAY,IAAI,gBAAgB;AACtC,WAAO,CAAC,KAAK,MAAM,UAAU,SAAS;AAAA,EACxC;AAEA,QAAM,cAAc,MAAM,OAAO,YAAY,GAAG,IAAI;AACpD,MAAI,cAAc,WAAW;AAC3B,UAAM,YAAY,IAAI,cAAc;AACpC,WAAO,KAAK,MAAM,UAAU,SAAS;AAAA,EACvC;AAEA,SAAO;AACT;AAEO,IAAM,2BAA2B,CAAC;AAAA,EACvC;AAAA,EACA,0BAA0B;AAC5B,MAAyB,CAAC,uBAAuB,CAAC;AAE3C,IAAM,4BAA4B,CAAC;AAAA,EACxC;AAAA,EACA;AACF,MACE,qBAAqB,IAAI,UAAU,KAClC,eAAe,YAAY,oBAAoB;AAE3C,IAAM,yBAAyB,CAAC;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AACF,MACE,WAAW,WACP,eAAe,YAAY,oBAAoB,WAC/C,eAAe;AAEd,IAAM,0BAA0B,CAAC;AAAA,EACtC;AAAA,EACA;AACF,OAA8D;AAAA,EAC5D,cAAc;AAAA,EACd;AAAA,EACA,iBACE,eAAe,YAAY,oBAAoB,WAC3C,QACA;AACR;AAEO,IAAM,6BAA6B,CAAC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,OAA8D;AAAA,EAC5D,IAAI,sBAAsB,GAAG,OAAO,WAAW,OAAO;AAAA,EACtD,IAAI,sBAAsB,GAAG,QAAQ,WAAW,OAAO;AACzD;","names":[]}
@@ -0,0 +1,101 @@
1
+ // gesture/pinchZoom.ts
2
+ var DEFAULT_PINCH_ZOOM_BOUNDS = {
3
+ minZoom: 0.5,
4
+ maxZoom: 4
5
+ };
6
+ var PINCH_PRESS_SUPPRESSION_MS = 120;
7
+ var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
8
+ var getTouchDistance = (touches) => {
9
+ if (touches.length < 2) return 0;
10
+ const [first, second] = touches;
11
+ return Math.hypot(second.pageX - first.pageX, second.pageY - first.pageY);
12
+ };
13
+ var isPinchTouchList = (touches) => touches.length === 2 && getTouchDistance(touches) > 0;
14
+ var createPinchSession = (touches, zoom, bounds = DEFAULT_PINCH_ZOOM_BOUNDS) => ({
15
+ initialDistance: Math.max(1, getTouchDistance(touches)),
16
+ initialZoom: clamp(zoom, bounds.minZoom, bounds.maxZoom)
17
+ });
18
+ var resolvePinchZoomChange = (session, touches, bounds = DEFAULT_PINCH_ZOOM_BOUNDS) => {
19
+ const distance = getTouchDistance(touches);
20
+ if (distance <= 0) {
21
+ return clamp(session.initialZoom, bounds.minZoom, bounds.maxZoom);
22
+ }
23
+ return clamp(
24
+ session.initialZoom * (distance / session.initialDistance),
25
+ bounds.minZoom,
26
+ bounds.maxZoom
27
+ );
28
+ };
29
+ var resolvePinchPreviewScale = (startZoom, previewZoom) => {
30
+ const safeStartZoom = Math.max(1e-4, Math.abs(startZoom));
31
+ return previewZoom / safeStartZoom;
32
+ };
33
+ var sanitizePinchPreviewScale = (value) => {
34
+ if (!Number.isFinite(value) || value <= 0) {
35
+ return 1;
36
+ }
37
+ return value;
38
+ };
39
+ var resolvePinchGestureZoom = (startZoom, scaleFactor, bounds = DEFAULT_PINCH_ZOOM_BOUNDS) => clamp(
40
+ (Number.isFinite(startZoom) && startZoom > 0 ? startZoom : 1) * (Number.isFinite(scaleFactor) && scaleFactor > 0 ? scaleFactor : 1),
41
+ bounds.minZoom,
42
+ bounds.maxZoom
43
+ );
44
+ var resolveAnchoredViewportOffset = ({
45
+ viewportOffset,
46
+ startScrollOffset,
47
+ startItemOffset,
48
+ startItemLength,
49
+ endItemOffset,
50
+ endItemLength,
51
+ viewportLength,
52
+ endContentLength
53
+ }) => {
54
+ const safeViewportOffset = Number.isFinite(viewportOffset) ? viewportOffset : 0;
55
+ const safeStartScrollOffset = Number.isFinite(startScrollOffset) ? startScrollOffset : 0;
56
+ const safeStartItemOffset = Number.isFinite(startItemOffset) ? startItemOffset : 0;
57
+ const safeStartItemLength = Number.isFinite(startItemLength) && startItemLength > 0 ? startItemLength : 1;
58
+ const safeEndItemOffset = Number.isFinite(endItemOffset) ? endItemOffset : 0;
59
+ const safeEndItemLength = Number.isFinite(endItemLength) && endItemLength > 0 ? endItemLength : 1;
60
+ const safeViewportLength = Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;
61
+ const safeEndContentLength = Number.isFinite(endContentLength) && endContentLength > 0 ? endContentLength : safeEndItemOffset + safeEndItemLength;
62
+ const contentPoint = safeStartScrollOffset + safeViewportOffset - safeStartItemOffset;
63
+ const normalizedPoint = clamp(contentPoint / safeStartItemLength, 0, 1);
64
+ const anchoredContentPoint = safeEndItemOffset + normalizedPoint * safeEndItemLength;
65
+ return clamp(
66
+ anchoredContentPoint - safeViewportOffset,
67
+ 0,
68
+ Math.max(0, safeEndContentLength - safeViewportLength)
69
+ );
70
+ };
71
+ var resolveClampedScrollOffset = (offset, contentLength, viewportLength) => {
72
+ const safeOffset = Number.isFinite(offset) ? offset : 0;
73
+ const safeContentLength = Number.isFinite(contentLength) && contentLength > 0 ? contentLength : 0;
74
+ const safeViewportLength = Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;
75
+ return clamp(
76
+ safeOffset,
77
+ 0,
78
+ Math.max(0, safeContentLength - safeViewportLength)
79
+ );
80
+ };
81
+ var shouldSuppressPressAfterPinch = (lastPinchEndedAt, now = Date.now(), windowMs = PINCH_PRESS_SUPPRESSION_MS) => {
82
+ if (typeof lastPinchEndedAt !== "number") return false;
83
+ const elapsedMs = now - lastPinchEndedAt;
84
+ return elapsedMs >= 0 && elapsedMs < windowMs;
85
+ };
86
+
87
+ export {
88
+ DEFAULT_PINCH_ZOOM_BOUNDS,
89
+ PINCH_PRESS_SUPPRESSION_MS,
90
+ getTouchDistance,
91
+ isPinchTouchList,
92
+ createPinchSession,
93
+ resolvePinchZoomChange,
94
+ resolvePinchPreviewScale,
95
+ sanitizePinchPreviewScale,
96
+ resolvePinchGestureZoom,
97
+ resolveAnchoredViewportOffset,
98
+ resolveClampedScrollOffset,
99
+ shouldSuppressPressAfterPinch
100
+ };
101
+ //# sourceMappingURL=chunk-PE5U4ZWV.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 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 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 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 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":"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","names":[]}
@@ -0,0 +1,9 @@
1
+ var __getOwnPropNames = Object.getOwnPropertyNames;
2
+ var __commonJS = (cb, mod) => function __require() {
3
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
4
+ };
5
+
6
+ export {
7
+ __commonJS
8
+ };
9
+ //# sourceMappingURL=chunk-ZD7AOCMD.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,135 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // gesture/pinchZoom.ts
20
+ var pinchZoom_exports = {};
21
+ __export(pinchZoom_exports, {
22
+ DEFAULT_PINCH_ZOOM_BOUNDS: () => DEFAULT_PINCH_ZOOM_BOUNDS,
23
+ PINCH_PRESS_SUPPRESSION_MS: () => PINCH_PRESS_SUPPRESSION_MS,
24
+ createPinchSession: () => createPinchSession,
25
+ getTouchDistance: () => getTouchDistance,
26
+ isPinchTouchList: () => isPinchTouchList,
27
+ resolveAnchoredViewportOffset: () => resolveAnchoredViewportOffset,
28
+ resolveClampedScrollOffset: () => resolveClampedScrollOffset,
29
+ resolvePinchGestureZoom: () => resolvePinchGestureZoom,
30
+ resolvePinchPreviewScale: () => resolvePinchPreviewScale,
31
+ resolvePinchZoomChange: () => resolvePinchZoomChange,
32
+ sanitizePinchPreviewScale: () => sanitizePinchPreviewScale,
33
+ shouldSuppressPressAfterPinch: () => shouldSuppressPressAfterPinch
34
+ });
35
+ module.exports = __toCommonJS(pinchZoom_exports);
36
+ var DEFAULT_PINCH_ZOOM_BOUNDS = {
37
+ minZoom: 0.5,
38
+ maxZoom: 4
39
+ };
40
+ var PINCH_PRESS_SUPPRESSION_MS = 120;
41
+ var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
42
+ var getTouchDistance = (touches) => {
43
+ if (touches.length < 2) return 0;
44
+ const [first, second] = touches;
45
+ return Math.hypot(second.pageX - first.pageX, second.pageY - first.pageY);
46
+ };
47
+ var isPinchTouchList = (touches) => touches.length === 2 && getTouchDistance(touches) > 0;
48
+ var createPinchSession = (touches, zoom, bounds = DEFAULT_PINCH_ZOOM_BOUNDS) => ({
49
+ initialDistance: Math.max(1, getTouchDistance(touches)),
50
+ initialZoom: clamp(zoom, bounds.minZoom, bounds.maxZoom)
51
+ });
52
+ var resolvePinchZoomChange = (session, touches, bounds = DEFAULT_PINCH_ZOOM_BOUNDS) => {
53
+ const distance = getTouchDistance(touches);
54
+ if (distance <= 0) {
55
+ return clamp(session.initialZoom, bounds.minZoom, bounds.maxZoom);
56
+ }
57
+ return clamp(
58
+ session.initialZoom * (distance / session.initialDistance),
59
+ bounds.minZoom,
60
+ bounds.maxZoom
61
+ );
62
+ };
63
+ var resolvePinchPreviewScale = (startZoom, previewZoom) => {
64
+ const safeStartZoom = Math.max(1e-4, Math.abs(startZoom));
65
+ return previewZoom / safeStartZoom;
66
+ };
67
+ var sanitizePinchPreviewScale = (value) => {
68
+ if (!Number.isFinite(value) || value <= 0) {
69
+ return 1;
70
+ }
71
+ return value;
72
+ };
73
+ var resolvePinchGestureZoom = (startZoom, scaleFactor, bounds = DEFAULT_PINCH_ZOOM_BOUNDS) => clamp(
74
+ (Number.isFinite(startZoom) && startZoom > 0 ? startZoom : 1) * (Number.isFinite(scaleFactor) && scaleFactor > 0 ? scaleFactor : 1),
75
+ bounds.minZoom,
76
+ bounds.maxZoom
77
+ );
78
+ var resolveAnchoredViewportOffset = ({
79
+ viewportOffset,
80
+ startScrollOffset,
81
+ startItemOffset,
82
+ startItemLength,
83
+ endItemOffset,
84
+ endItemLength,
85
+ viewportLength,
86
+ endContentLength
87
+ }) => {
88
+ const safeViewportOffset = Number.isFinite(viewportOffset) ? viewportOffset : 0;
89
+ const safeStartScrollOffset = Number.isFinite(startScrollOffset) ? startScrollOffset : 0;
90
+ const safeStartItemOffset = Number.isFinite(startItemOffset) ? startItemOffset : 0;
91
+ const safeStartItemLength = Number.isFinite(startItemLength) && startItemLength > 0 ? startItemLength : 1;
92
+ const safeEndItemOffset = Number.isFinite(endItemOffset) ? endItemOffset : 0;
93
+ const safeEndItemLength = Number.isFinite(endItemLength) && endItemLength > 0 ? endItemLength : 1;
94
+ const safeViewportLength = Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;
95
+ const safeEndContentLength = Number.isFinite(endContentLength) && endContentLength > 0 ? endContentLength : safeEndItemOffset + safeEndItemLength;
96
+ const contentPoint = safeStartScrollOffset + safeViewportOffset - safeStartItemOffset;
97
+ const normalizedPoint = clamp(contentPoint / safeStartItemLength, 0, 1);
98
+ const anchoredContentPoint = safeEndItemOffset + normalizedPoint * safeEndItemLength;
99
+ return clamp(
100
+ anchoredContentPoint - safeViewportOffset,
101
+ 0,
102
+ Math.max(0, safeEndContentLength - safeViewportLength)
103
+ );
104
+ };
105
+ var resolveClampedScrollOffset = (offset, contentLength, viewportLength) => {
106
+ const safeOffset = Number.isFinite(offset) ? offset : 0;
107
+ const safeContentLength = Number.isFinite(contentLength) && contentLength > 0 ? contentLength : 0;
108
+ const safeViewportLength = Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;
109
+ return clamp(
110
+ safeOffset,
111
+ 0,
112
+ Math.max(0, safeContentLength - safeViewportLength)
113
+ );
114
+ };
115
+ var shouldSuppressPressAfterPinch = (lastPinchEndedAt, now = Date.now(), windowMs = PINCH_PRESS_SUPPRESSION_MS) => {
116
+ if (typeof lastPinchEndedAt !== "number") return false;
117
+ const elapsedMs = now - lastPinchEndedAt;
118
+ return elapsedMs >= 0 && elapsedMs < windowMs;
119
+ };
120
+ // Annotate the CommonJS export names for ESM import in node:
121
+ 0 && (module.exports = {
122
+ DEFAULT_PINCH_ZOOM_BOUNDS,
123
+ PINCH_PRESS_SUPPRESSION_MS,
124
+ createPinchSession,
125
+ getTouchDistance,
126
+ isPinchTouchList,
127
+ resolveAnchoredViewportOffset,
128
+ resolveClampedScrollOffset,
129
+ resolvePinchGestureZoom,
130
+ resolvePinchPreviewScale,
131
+ resolvePinchZoomChange,
132
+ sanitizePinchPreviewScale,
133
+ shouldSuppressPressAfterPinch
134
+ });
135
+ //# sourceMappingURL=pinchZoom.js.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 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 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 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 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":"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","names":[]}
@@ -0,0 +1,30 @@
1
+ import {
2
+ DEFAULT_PINCH_ZOOM_BOUNDS,
3
+ PINCH_PRESS_SUPPRESSION_MS,
4
+ createPinchSession,
5
+ getTouchDistance,
6
+ isPinchTouchList,
7
+ resolveAnchoredViewportOffset,
8
+ resolveClampedScrollOffset,
9
+ resolvePinchGestureZoom,
10
+ resolvePinchPreviewScale,
11
+ resolvePinchZoomChange,
12
+ sanitizePinchPreviewScale,
13
+ shouldSuppressPressAfterPinch
14
+ } from "../chunk-PE5U4ZWV.mjs";
15
+ import "../chunk-ZD7AOCMD.mjs";
16
+ export {
17
+ DEFAULT_PINCH_ZOOM_BOUNDS,
18
+ PINCH_PRESS_SUPPRESSION_MS,
19
+ createPinchSession,
20
+ getTouchDistance,
21
+ isPinchTouchList,
22
+ resolveAnchoredViewportOffset,
23
+ resolveClampedScrollOffset,
24
+ resolvePinchGestureZoom,
25
+ resolvePinchPreviewScale,
26
+ resolvePinchZoomChange,
27
+ sanitizePinchPreviewScale,
28
+ shouldSuppressPressAfterPinch
29
+ };
30
+ //# sourceMappingURL=pinchZoom.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,90 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // gesture/selectionInteraction.ts
20
+ var selectionInteraction_exports = {};
21
+ __export(selectionInteraction_exports, {
22
+ getSelectionEdgeAutoscroll: () => getSelectionEdgeAutoscroll,
23
+ getToolDockDismissState: () => getToolDockDismissState,
24
+ isToolDockToolSelected: () => isToolDockToolSelected,
25
+ shouldEnableSelectionDrag: () => shouldEnableSelectionDrag,
26
+ shouldEnableViewerScroll: () => shouldEnableViewerScroll
27
+ });
28
+ module.exports = __toCommonJS(selectionInteraction_exports);
29
+ var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
30
+ var DRAG_SELECTION_TOOLS = /* @__PURE__ */ new Set([
31
+ "highlight",
32
+ "underline",
33
+ "squiggly",
34
+ "strikeout"
35
+ ]);
36
+ var resolveAxisAutoscroll = (coordinate, size, threshold, maxStep) => {
37
+ if (size <= 0 || threshold <= 0 || maxStep <= 0) return 0;
38
+ const startDistance = clamp(coordinate, 0, size);
39
+ if (startDistance < threshold) {
40
+ const intensity = 1 - startDistance / threshold;
41
+ return -Math.round(maxStep * intensity);
42
+ }
43
+ const endDistance = clamp(size - coordinate, 0, size);
44
+ if (endDistance < threshold) {
45
+ const intensity = 1 - endDistance / threshold;
46
+ return Math.round(maxStep * intensity);
47
+ }
48
+ return 0;
49
+ };
50
+ var shouldEnableViewerScroll = ({
51
+ selectionDragActive,
52
+ gestureScrollLockActive = false
53
+ }) => !selectionDragActive && !gestureScrollLockActive;
54
+ var shouldEnableSelectionDrag = ({
55
+ activeTool,
56
+ interactionMode
57
+ }) => DRAG_SELECTION_TOOLS.has(activeTool) || activeTool === "select" && interactionMode === "select";
58
+ var isToolDockToolSelected = ({
59
+ activeTool,
60
+ interactionMode,
61
+ toolId
62
+ }) => toolId === "select" ? activeTool === "select" && interactionMode === "select" : activeTool === toolId;
63
+ var getToolDockDismissState = ({
64
+ activeTool,
65
+ interactionMode
66
+ }) => ({
67
+ toolDockOpen: false,
68
+ activeTool,
69
+ interactionMode: activeTool === "select" && interactionMode === "select" ? "pan" : interactionMode
70
+ });
71
+ var getSelectionEdgeAutoscroll = ({
72
+ x,
73
+ y,
74
+ width,
75
+ height,
76
+ threshold,
77
+ maxStep
78
+ }) => ({
79
+ dx: resolveAxisAutoscroll(x, width, threshold, maxStep),
80
+ dy: resolveAxisAutoscroll(y, height, threshold, maxStep)
81
+ });
82
+ // Annotate the CommonJS export names for ESM import in node:
83
+ 0 && (module.exports = {
84
+ getSelectionEdgeAutoscroll,
85
+ getToolDockDismissState,
86
+ isToolDockToolSelected,
87
+ shouldEnableSelectionDrag,
88
+ shouldEnableViewerScroll
89
+ });
90
+ //# sourceMappingURL=selectionInteraction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../gesture/selectionInteraction.ts"],"sourcesContent":["export type ViewerScrollState = {\n selectionDragActive: boolean;\n gestureScrollLockActive?: boolean;\n};\n\nexport type SelectionGestureTool =\n | \"select\"\n | \"highlight\"\n | \"underline\"\n | \"squiggly\"\n | \"strikeout\"\n | \"text\"\n | \"comment\"\n | \"ink\";\n\nexport type SelectionInteractionMode = \"pan\" | \"select\";\n\nexport type SelectionGestureActivationInput = {\n activeTool: SelectionGestureTool;\n interactionMode: SelectionInteractionMode;\n};\n\nexport type ToolDockSelectionState = SelectionGestureActivationInput & {\n toolId: SelectionGestureTool;\n};\n\nexport type ToolDockDismissState = SelectionGestureActivationInput & {\n toolDockOpen: boolean;\n};\n\nexport type SelectionEdgeAutoscrollInput = {\n x: number;\n y: number;\n width: number;\n height: number;\n threshold: number;\n maxStep: number;\n};\n\nexport type SelectionEdgeAutoscroll = {\n dx: number;\n dy: number;\n};\n\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(max, Math.max(min, value));\n\nconst DRAG_SELECTION_TOOLS = new Set<SelectionGestureTool>([\n \"highlight\",\n \"underline\",\n \"squiggly\",\n \"strikeout\",\n]);\n\nconst resolveAxisAutoscroll = (\n coordinate: number,\n size: number,\n threshold: number,\n maxStep: number\n) => {\n if (size <= 0 || threshold <= 0 || maxStep <= 0) return 0;\n\n const startDistance = clamp(coordinate, 0, size);\n if (startDistance < threshold) {\n const intensity = 1 - startDistance / threshold;\n return -Math.round(maxStep * intensity);\n }\n\n const endDistance = clamp(size - coordinate, 0, size);\n if (endDistance < threshold) {\n const intensity = 1 - endDistance / threshold;\n return Math.round(maxStep * intensity);\n }\n\n return 0;\n};\n\nexport const shouldEnableViewerScroll = ({\n selectionDragActive,\n gestureScrollLockActive = false,\n}: ViewerScrollState) => !selectionDragActive && !gestureScrollLockActive;\n\nexport const shouldEnableSelectionDrag = ({\n activeTool,\n interactionMode,\n}: SelectionGestureActivationInput) =>\n DRAG_SELECTION_TOOLS.has(activeTool) ||\n (activeTool === \"select\" && interactionMode === \"select\");\n\nexport const isToolDockToolSelected = ({\n activeTool,\n interactionMode,\n toolId,\n}: ToolDockSelectionState) =>\n toolId === \"select\"\n ? activeTool === \"select\" && interactionMode === \"select\"\n : activeTool === toolId;\n\nexport const getToolDockDismissState = ({\n activeTool,\n interactionMode,\n}: SelectionGestureActivationInput): ToolDockDismissState => ({\n toolDockOpen: false,\n activeTool,\n interactionMode:\n activeTool === \"select\" && interactionMode === \"select\"\n ? \"pan\"\n : interactionMode,\n});\n\nexport const getSelectionEdgeAutoscroll = ({\n x,\n y,\n width,\n height,\n threshold,\n maxStep,\n}: SelectionEdgeAutoscrollInput): SelectionEdgeAutoscroll => ({\n dx: resolveAxisAutoscroll(x, width, threshold, maxStep),\n dy: resolveAxisAutoscroll(y, height, threshold, maxStep),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4CA,IAAM,QAAQ,CAAC,OAAe,KAAa,QACzC,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC;AAEpC,IAAM,uBAAuB,oBAAI,IAA0B;AAAA,EACzD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,wBAAwB,CAC5B,YACA,MACA,WACA,YACG;AACH,MAAI,QAAQ,KAAK,aAAa,KAAK,WAAW,EAAG,QAAO;AAExD,QAAM,gBAAgB,MAAM,YAAY,GAAG,IAAI;AAC/C,MAAI,gBAAgB,WAAW;AAC7B,UAAM,YAAY,IAAI,gBAAgB;AACtC,WAAO,CAAC,KAAK,MAAM,UAAU,SAAS;AAAA,EACxC;AAEA,QAAM,cAAc,MAAM,OAAO,YAAY,GAAG,IAAI;AACpD,MAAI,cAAc,WAAW;AAC3B,UAAM,YAAY,IAAI,cAAc;AACpC,WAAO,KAAK,MAAM,UAAU,SAAS;AAAA,EACvC;AAEA,SAAO;AACT;AAEO,IAAM,2BAA2B,CAAC;AAAA,EACvC;AAAA,EACA,0BAA0B;AAC5B,MAAyB,CAAC,uBAAuB,CAAC;AAE3C,IAAM,4BAA4B,CAAC;AAAA,EACxC;AAAA,EACA;AACF,MACE,qBAAqB,IAAI,UAAU,KAClC,eAAe,YAAY,oBAAoB;AAE3C,IAAM,yBAAyB,CAAC;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AACF,MACE,WAAW,WACP,eAAe,YAAY,oBAAoB,WAC/C,eAAe;AAEd,IAAM,0BAA0B,CAAC;AAAA,EACtC;AAAA,EACA;AACF,OAA8D;AAAA,EAC5D,cAAc;AAAA,EACd;AAAA,EACA,iBACE,eAAe,YAAY,oBAAoB,WAC3C,QACA;AACR;AAEO,IAAM,6BAA6B,CAAC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,OAA8D;AAAA,EAC5D,IAAI,sBAAsB,GAAG,OAAO,WAAW,OAAO;AAAA,EACtD,IAAI,sBAAsB,GAAG,QAAQ,WAAW,OAAO;AACzD;","names":[]}
@@ -0,0 +1,16 @@
1
+ import {
2
+ getSelectionEdgeAutoscroll,
3
+ getToolDockDismissState,
4
+ isToolDockToolSelected,
5
+ shouldEnableSelectionDrag,
6
+ shouldEnableViewerScroll
7
+ } from "../chunk-GCVUTXFR.mjs";
8
+ import "../chunk-ZD7AOCMD.mjs";
9
+ export {
10
+ getSelectionEdgeAutoscroll,
11
+ getToolDockDismissState,
12
+ isToolDockToolSelected,
13
+ shouldEnableSelectionDrag,
14
+ shouldEnableViewerScroll
15
+ };
16
+ //# sourceMappingURL=selectionInteraction.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/index.d.mts CHANGED
@@ -1,73 +1,11 @@
1
- import React from 'react';
2
- import { DocumentEngine, DocumentSource, DocumentType } from '@papyrus-sdk/types';
3
- import { PapyrusPageViewProps } from '@papyrus-sdk/engine-native';
4
- import { StyleProp, ViewStyle } from 'react-native';
5
-
6
- interface ViewerProps {
7
- engine: DocumentEngine;
8
- virtualWindowSize?: number;
9
- maxToRenderPerBatch?: number;
10
- removeClippedSubviews?: boolean;
11
- }
12
- declare const Viewer: React.FC<ViewerProps>;
13
-
14
- type PageViewComponentType = React.ComponentType<PapyrusPageViewProps & React.RefAttributes<any>>;
15
- interface PageRendererProps {
16
- engine: DocumentEngine;
17
- pageIndex: number;
18
- scale?: number;
19
- PageViewComponent?: PageViewComponentType;
20
- availableWidth?: number;
21
- horizontalPadding?: number;
22
- spacing?: number;
23
- }
24
- declare const _default: React.NamedExoticComponent<PageRendererProps>;
25
-
26
- interface TopbarProps {
27
- engine: DocumentEngine;
28
- onOpenSettings?: () => void;
29
- title?: string;
30
- logo?: React.ReactNode;
31
- onLogoPress?: () => void;
32
- logoAccessibilityLabel?: string;
33
- }
34
- declare const Topbar: React.FC<TopbarProps>;
35
-
36
- declare const ToolDock: React.FC;
37
-
38
- interface RightSheetProps {
39
- engine: DocumentEngine;
40
- thumbsInitialCount?: number;
41
- }
42
- declare const RightSheet: React.FC<RightSheetProps>;
43
-
44
- declare const AnnotationEditor: React.FC;
45
-
46
- declare const BottomBar: React.FC;
47
-
48
- interface SettingsSheetProps {
49
- engine: DocumentEngine;
50
- visible: boolean;
51
- onClose: () => void;
52
- }
53
- declare const SettingsSheet: React.FC<SettingsSheetProps>;
54
-
55
- type CoverPreviewProps = {
56
- source: DocumentSource;
57
- type?: DocumentType;
58
- pageIndex?: number;
59
- visible?: boolean;
60
- keepAlive?: boolean;
61
- allowInteraction?: boolean;
62
- renderScale?: number;
63
- showLoading?: boolean;
64
- loadingIndicator?: React.ReactNode;
65
- placeholder?: React.ReactNode;
66
- style?: StyleProp<ViewStyle>;
67
- onLoadStart?: () => void;
68
- onLoadEnd?: () => void;
69
- onError?: (error: Error) => void;
70
- };
71
- declare const CoverPreview: React.FC<CoverPreviewProps>;
72
-
73
- export { AnnotationEditor, BottomBar, CoverPreview, _default as PageRenderer, RightSheet, SettingsSheet, ToolDock, Topbar, Viewer };
1
+ import type React from "react";
2
+
3
+ export declare const Viewer: React.ComponentType<any>;
4
+ export declare const PageRenderer: React.ComponentType<any>;
5
+ export declare const Topbar: React.ComponentType<any>;
6
+ export declare const ToolDock: React.ComponentType<any>;
7
+ export declare const RightSheet: React.ComponentType<any>;
8
+ export declare const AnnotationEditor: React.ComponentType<any>;
9
+ export declare const BottomBar: React.ComponentType<any>;
10
+ export declare const SettingsSheet: React.ComponentType<any>;
11
+ export declare const CoverPreview: React.ComponentType<any>;