@papyrus-sdk/ui-react-native 0.2.31 → 0.2.34
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 +9 -1
- package/dist/{chunk-KXNP73MZ.mjs → chunk-G6AQ4BV5.mjs} +29 -2
- package/dist/chunk-G6AQ4BV5.mjs.map +1 -0
- package/dist/gesture/selectionInteraction.d.mts +18 -1
- package/dist/gesture/selectionInteraction.d.ts +18 -1
- package/dist/gesture/selectionInteraction.js +28 -0
- package/dist/gesture/selectionInteraction.js.map +1 -1
- package/dist/gesture/selectionInteraction.mjs +3 -1
- package/dist/index.d.mts +20 -2
- package/dist/index.d.ts +20 -2
- package/dist/index.js +3832 -3274
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3641 -3105
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-KXNP73MZ.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -83,11 +83,13 @@ await engine.load({ type: 'pdf', source: { uri: 'https://example.com/book.pdf' }
|
|
|
83
83
|
|
|
84
84
|
## Mobile Tuning Flags
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
Layout and performance options are available on `Viewer` and `RightSheet`:
|
|
87
87
|
|
|
88
88
|
```tsx
|
|
89
89
|
<Viewer
|
|
90
90
|
engine={engine}
|
|
91
|
+
maxPageWidth={760}
|
|
92
|
+
fitPageToViewportHeight
|
|
91
93
|
virtualWindowSize={8}
|
|
92
94
|
maxToRenderPerBatch={6}
|
|
93
95
|
removeClippedSubviews
|
|
@@ -97,6 +99,12 @@ Performance tuning props are available on `Viewer` and `RightSheet`:
|
|
|
97
99
|
```
|
|
98
100
|
|
|
99
101
|
- `virtualWindowSize` (`Viewer`): FlatList window size. Default: `8`.
|
|
102
|
+
- `maxPageWidth` (`Viewer`): optional fit-zoom width limit in React Native points. A narrower page is centered in the viewport; pinch zoom may enlarge it. Omitted by default.
|
|
103
|
+
- `fitPageToViewportHeight` (`Viewer`): opt-in page fitting to the measured
|
|
104
|
+
viewer height while preserving each page's aspect ratio; pinch zoom may
|
|
105
|
+
enlarge it. Defaults to `false`. This option is only supported by the React
|
|
106
|
+
Native compatibility renderer; it is not applied by the WebView or dedicated
|
|
107
|
+
Android PDF renderer.
|
|
100
108
|
- `maxToRenderPerBatch` (`Viewer`): max items per render batch. Default: `6`.
|
|
101
109
|
- `removeClippedSubviews` (`Viewer`): detach offscreen rows. Default: `false`
|
|
102
110
|
for Android `viewerMode="compat"` and `true` otherwise. An explicit value is
|
|
@@ -52,12 +52,39 @@ var getSelectionEdgeAutoscroll = ({
|
|
|
52
52
|
dx: resolveAxisAutoscroll(x, width, threshold, maxStep),
|
|
53
53
|
dy: resolveAxisAutoscroll(y, height, threshold, maxStep)
|
|
54
54
|
});
|
|
55
|
+
var resolveSelectionDragRect = ({
|
|
56
|
+
start,
|
|
57
|
+
end,
|
|
58
|
+
width,
|
|
59
|
+
height,
|
|
60
|
+
lineThreshold
|
|
61
|
+
}) => {
|
|
62
|
+
const top = Math.max(0, Math.min(start.y, end.y));
|
|
63
|
+
const bottom = Math.min(height, Math.max(start.y, end.y));
|
|
64
|
+
const crossesLine = Math.abs(end.y - start.y) > lineThreshold;
|
|
65
|
+
if (!crossesLine) {
|
|
66
|
+
const left2 = Math.max(0, Math.min(start.x, end.x));
|
|
67
|
+
const right2 = Math.min(width, Math.max(start.x, end.x));
|
|
68
|
+
return { x: left2, y: top, width: right2 - left2, height: bottom - top };
|
|
69
|
+
}
|
|
70
|
+
const left = end.y >= start.y ? start.x : 0;
|
|
71
|
+
const right = end.y >= start.y ? width : start.x;
|
|
72
|
+
const clampedLeft = Math.max(0, Math.min(width, left));
|
|
73
|
+
const clampedRight = Math.max(clampedLeft, Math.min(width, right));
|
|
74
|
+
return {
|
|
75
|
+
x: clampedLeft,
|
|
76
|
+
y: top,
|
|
77
|
+
width: clampedRight - clampedLeft,
|
|
78
|
+
height: bottom - top
|
|
79
|
+
};
|
|
80
|
+
};
|
|
55
81
|
|
|
56
82
|
export {
|
|
57
83
|
shouldEnableViewerScroll,
|
|
58
84
|
shouldEnableSelectionDrag,
|
|
59
85
|
isToolDockToolSelected,
|
|
60
86
|
getToolDockDismissState,
|
|
61
|
-
getSelectionEdgeAutoscroll
|
|
87
|
+
getSelectionEdgeAutoscroll,
|
|
88
|
+
resolveSelectionDragRect
|
|
62
89
|
};
|
|
63
|
-
//# sourceMappingURL=chunk-
|
|
90
|
+
//# sourceMappingURL=chunk-G6AQ4BV5.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\nexport type SelectionDragPoint = {\n x: number;\n y: number;\n};\n\nexport type SelectionDragRectInput = {\n start: SelectionDragPoint;\n end: SelectionDragPoint;\n width: number;\n height: number;\n lineThreshold: 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: _activeTool,\n interactionMode: _interactionMode,\n}: SelectionGestureActivationInput): ToolDockDismissState => ({\n toolDockOpen: false,\n activeTool: \"select\",\n interactionMode: \"pan\",\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\nexport const resolveSelectionDragRect = ({\n start,\n end,\n width,\n height,\n lineThreshold,\n}: SelectionDragRectInput) => {\n const top = Math.max(0, Math.min(start.y, end.y));\n const bottom = Math.min(height, Math.max(start.y, end.y));\n const crossesLine = Math.abs(end.y - start.y) > lineThreshold;\n\n if (!crossesLine) {\n const left = Math.max(0, Math.min(start.x, end.x));\n const right = Math.min(width, Math.max(start.x, end.x));\n return { x: left, y: top, width: right - left, height: bottom - top };\n }\n\n const left = end.y >= start.y ? start.x : 0;\n const right = end.y >= start.y ? width : start.x;\n const clampedLeft = Math.max(0, Math.min(width, left));\n const clampedRight = Math.max(clampedLeft, Math.min(width, right));\n return {\n x: clampedLeft,\n y: top,\n width: clampedRight - clampedLeft,\n height: bottom - top,\n };\n};\n"],"mappings":";AAyDA,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,YAAY;AAAA,EACZ,iBAAiB;AACnB,OAA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":["left","right"]}
|
|
@@ -26,10 +26,27 @@ type SelectionEdgeAutoscroll = {
|
|
|
26
26
|
dx: number;
|
|
27
27
|
dy: number;
|
|
28
28
|
};
|
|
29
|
+
type SelectionDragPoint = {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
};
|
|
33
|
+
type SelectionDragRectInput = {
|
|
34
|
+
start: SelectionDragPoint;
|
|
35
|
+
end: SelectionDragPoint;
|
|
36
|
+
width: number;
|
|
37
|
+
height: number;
|
|
38
|
+
lineThreshold: number;
|
|
39
|
+
};
|
|
29
40
|
declare const shouldEnableViewerScroll: ({ selectionDragActive, gestureScrollLockActive, }: ViewerScrollState) => boolean;
|
|
30
41
|
declare const shouldEnableSelectionDrag: ({ activeTool, interactionMode, }: SelectionGestureActivationInput) => boolean;
|
|
31
42
|
declare const isToolDockToolSelected: ({ activeTool, interactionMode, toolId, }: ToolDockSelectionState) => boolean;
|
|
32
43
|
declare const getToolDockDismissState: ({ activeTool: _activeTool, interactionMode: _interactionMode, }: SelectionGestureActivationInput) => ToolDockDismissState;
|
|
33
44
|
declare const getSelectionEdgeAutoscroll: ({ x, y, width, height, threshold, maxStep, }: SelectionEdgeAutoscrollInput) => SelectionEdgeAutoscroll;
|
|
45
|
+
declare const resolveSelectionDragRect: ({ start, end, width, height, lineThreshold, }: SelectionDragRectInput) => {
|
|
46
|
+
x: number;
|
|
47
|
+
y: number;
|
|
48
|
+
width: number;
|
|
49
|
+
height: number;
|
|
50
|
+
};
|
|
34
51
|
|
|
35
|
-
export { type SelectionEdgeAutoscroll, type SelectionEdgeAutoscrollInput, type SelectionGestureActivationInput, type SelectionGestureTool, type SelectionInteractionMode, type ToolDockDismissState, type ToolDockSelectionState, type ViewerScrollState, getSelectionEdgeAutoscroll, getToolDockDismissState, isToolDockToolSelected, shouldEnableSelectionDrag, shouldEnableViewerScroll };
|
|
52
|
+
export { type SelectionDragPoint, type SelectionDragRectInput, type SelectionEdgeAutoscroll, type SelectionEdgeAutoscrollInput, type SelectionGestureActivationInput, type SelectionGestureTool, type SelectionInteractionMode, type ToolDockDismissState, type ToolDockSelectionState, type ViewerScrollState, getSelectionEdgeAutoscroll, getToolDockDismissState, isToolDockToolSelected, resolveSelectionDragRect, shouldEnableSelectionDrag, shouldEnableViewerScroll };
|
|
@@ -26,10 +26,27 @@ type SelectionEdgeAutoscroll = {
|
|
|
26
26
|
dx: number;
|
|
27
27
|
dy: number;
|
|
28
28
|
};
|
|
29
|
+
type SelectionDragPoint = {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
};
|
|
33
|
+
type SelectionDragRectInput = {
|
|
34
|
+
start: SelectionDragPoint;
|
|
35
|
+
end: SelectionDragPoint;
|
|
36
|
+
width: number;
|
|
37
|
+
height: number;
|
|
38
|
+
lineThreshold: number;
|
|
39
|
+
};
|
|
29
40
|
declare const shouldEnableViewerScroll: ({ selectionDragActive, gestureScrollLockActive, }: ViewerScrollState) => boolean;
|
|
30
41
|
declare const shouldEnableSelectionDrag: ({ activeTool, interactionMode, }: SelectionGestureActivationInput) => boolean;
|
|
31
42
|
declare const isToolDockToolSelected: ({ activeTool, interactionMode, toolId, }: ToolDockSelectionState) => boolean;
|
|
32
43
|
declare const getToolDockDismissState: ({ activeTool: _activeTool, interactionMode: _interactionMode, }: SelectionGestureActivationInput) => ToolDockDismissState;
|
|
33
44
|
declare const getSelectionEdgeAutoscroll: ({ x, y, width, height, threshold, maxStep, }: SelectionEdgeAutoscrollInput) => SelectionEdgeAutoscroll;
|
|
45
|
+
declare const resolveSelectionDragRect: ({ start, end, width, height, lineThreshold, }: SelectionDragRectInput) => {
|
|
46
|
+
x: number;
|
|
47
|
+
y: number;
|
|
48
|
+
width: number;
|
|
49
|
+
height: number;
|
|
50
|
+
};
|
|
34
51
|
|
|
35
|
-
export { type SelectionEdgeAutoscroll, type SelectionEdgeAutoscrollInput, type SelectionGestureActivationInput, type SelectionGestureTool, type SelectionInteractionMode, type ToolDockDismissState, type ToolDockSelectionState, type ViewerScrollState, getSelectionEdgeAutoscroll, getToolDockDismissState, isToolDockToolSelected, shouldEnableSelectionDrag, shouldEnableViewerScroll };
|
|
52
|
+
export { type SelectionDragPoint, type SelectionDragRectInput, type SelectionEdgeAutoscroll, type SelectionEdgeAutoscrollInput, type SelectionGestureActivationInput, type SelectionGestureTool, type SelectionInteractionMode, type ToolDockDismissState, type ToolDockSelectionState, type ViewerScrollState, getSelectionEdgeAutoscroll, getToolDockDismissState, isToolDockToolSelected, resolveSelectionDragRect, shouldEnableSelectionDrag, shouldEnableViewerScroll };
|
|
@@ -22,6 +22,7 @@ __export(selectionInteraction_exports, {
|
|
|
22
22
|
getSelectionEdgeAutoscroll: () => getSelectionEdgeAutoscroll,
|
|
23
23
|
getToolDockDismissState: () => getToolDockDismissState,
|
|
24
24
|
isToolDockToolSelected: () => isToolDockToolSelected,
|
|
25
|
+
resolveSelectionDragRect: () => resolveSelectionDragRect,
|
|
25
26
|
shouldEnableSelectionDrag: () => shouldEnableSelectionDrag,
|
|
26
27
|
shouldEnableViewerScroll: () => shouldEnableViewerScroll
|
|
27
28
|
});
|
|
@@ -79,11 +80,38 @@ var getSelectionEdgeAutoscroll = ({
|
|
|
79
80
|
dx: resolveAxisAutoscroll(x, width, threshold, maxStep),
|
|
80
81
|
dy: resolveAxisAutoscroll(y, height, threshold, maxStep)
|
|
81
82
|
});
|
|
83
|
+
var resolveSelectionDragRect = ({
|
|
84
|
+
start,
|
|
85
|
+
end,
|
|
86
|
+
width,
|
|
87
|
+
height,
|
|
88
|
+
lineThreshold
|
|
89
|
+
}) => {
|
|
90
|
+
const top = Math.max(0, Math.min(start.y, end.y));
|
|
91
|
+
const bottom = Math.min(height, Math.max(start.y, end.y));
|
|
92
|
+
const crossesLine = Math.abs(end.y - start.y) > lineThreshold;
|
|
93
|
+
if (!crossesLine) {
|
|
94
|
+
const left2 = Math.max(0, Math.min(start.x, end.x));
|
|
95
|
+
const right2 = Math.min(width, Math.max(start.x, end.x));
|
|
96
|
+
return { x: left2, y: top, width: right2 - left2, height: bottom - top };
|
|
97
|
+
}
|
|
98
|
+
const left = end.y >= start.y ? start.x : 0;
|
|
99
|
+
const right = end.y >= start.y ? width : start.x;
|
|
100
|
+
const clampedLeft = Math.max(0, Math.min(width, left));
|
|
101
|
+
const clampedRight = Math.max(clampedLeft, Math.min(width, right));
|
|
102
|
+
return {
|
|
103
|
+
x: clampedLeft,
|
|
104
|
+
y: top,
|
|
105
|
+
width: clampedRight - clampedLeft,
|
|
106
|
+
height: bottom - top
|
|
107
|
+
};
|
|
108
|
+
};
|
|
82
109
|
// Annotate the CommonJS export names for ESM import in node:
|
|
83
110
|
0 && (module.exports = {
|
|
84
111
|
getSelectionEdgeAutoscroll,
|
|
85
112
|
getToolDockDismissState,
|
|
86
113
|
isToolDockToolSelected,
|
|
114
|
+
resolveSelectionDragRect,
|
|
87
115
|
shouldEnableSelectionDrag,
|
|
88
116
|
shouldEnableViewerScroll
|
|
89
117
|
});
|
|
@@ -1 +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: _activeTool,\n interactionMode: _interactionMode,\n}: SelectionGestureActivationInput): ToolDockDismissState => ({\n toolDockOpen: false,\n activeTool: \"select\",\n interactionMode: \"pan\",\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;
|
|
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\nexport type SelectionDragPoint = {\n x: number;\n y: number;\n};\n\nexport type SelectionDragRectInput = {\n start: SelectionDragPoint;\n end: SelectionDragPoint;\n width: number;\n height: number;\n lineThreshold: 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: _activeTool,\n interactionMode: _interactionMode,\n}: SelectionGestureActivationInput): ToolDockDismissState => ({\n toolDockOpen: false,\n activeTool: \"select\",\n interactionMode: \"pan\",\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\nexport const resolveSelectionDragRect = ({\n start,\n end,\n width,\n height,\n lineThreshold,\n}: SelectionDragRectInput) => {\n const top = Math.max(0, Math.min(start.y, end.y));\n const bottom = Math.min(height, Math.max(start.y, end.y));\n const crossesLine = Math.abs(end.y - start.y) > lineThreshold;\n\n if (!crossesLine) {\n const left = Math.max(0, Math.min(start.x, end.x));\n const right = Math.min(width, Math.max(start.x, end.x));\n return { x: left, y: top, width: right - left, height: bottom - top };\n }\n\n const left = end.y >= start.y ? start.x : 0;\n const right = end.y >= start.y ? width : start.x;\n const clampedLeft = Math.max(0, Math.min(width, left));\n const clampedRight = Math.max(clampedLeft, Math.min(width, right));\n return {\n x: clampedLeft,\n y: top,\n width: clampedRight - clampedLeft,\n height: bottom - top,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyDA,IAAM,QAAQ,CAAC,OAAe,KAAa,QACzC,KA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zD;AAEO,IAAM,2BAA2B,CAAC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA8B;AAC5B,QAAM,MAAM,KAAK,IAAI,GAAG,KAAK,IAAI,MAAM,GAAG,IAAI,CAAC,CAAC;AAChD,QAAM,SAAS,KAAK,IAAI,QAAQ,KAAK,IAAI,MAAM,GAAG,IAAI,CAAC,CAAC;AACxD,QAAM,cAAc,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI;AAEhD,MAAI,CAAC,aAAa;AAChB,UAAMA,QAAO,KAAK,IAAI,GAAG,KAAK,IAAI,MAAM,GAAG,IAAI,CAAC,CAAC;AACjD,UAAMC,SAAQ,KAAK,IAAI,OAAO,KAAK,IAAI,MAAM,GAAG,IAAI,CAAC,CAAC;AACtD,WAAO,EAAE,GAAGD,OAAM,GAAG,KAAK,OAAOC,SAAQD,OAAM,QAAQ,SAAS,IAAI;AAAA,EACtE;AAEA,QAAM,OAAO,IAAI,KAAK,MAAM,IAAI,MAAM,IAAI;AAC1C,QAAM,QAAQ,IAAI,KAAK,MAAM,IAAI,QAAQ,MAAM;AAC/C,QAAM,cAAc,KAAK,IAAI,GAAG,KAAK,IAAI,OAAO,IAAI,CAAC;AACrD,QAAM,eAAe,KAAK,IAAI,aAAa,KAAK,IAAI,OAAO,KAAK,CAAC;AACjE,SAAO;AAAA,IACL,GAAG;AAAA,IACH,GAAG;AAAA,IACH,OAAO,eAAe;AAAA,IACtB,QAAQ,SAAS;AAAA,EACnB;AACF;","names":["left","right"]}
|
|
@@ -2,14 +2,16 @@ import {
|
|
|
2
2
|
getSelectionEdgeAutoscroll,
|
|
3
3
|
getToolDockDismissState,
|
|
4
4
|
isToolDockToolSelected,
|
|
5
|
+
resolveSelectionDragRect,
|
|
5
6
|
shouldEnableSelectionDrag,
|
|
6
7
|
shouldEnableViewerScroll
|
|
7
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-G6AQ4BV5.mjs";
|
|
8
9
|
import "../chunk-ZD7AOCMD.mjs";
|
|
9
10
|
export {
|
|
10
11
|
getSelectionEdgeAutoscroll,
|
|
11
12
|
getToolDockDismissState,
|
|
12
13
|
isToolDockToolSelected,
|
|
14
|
+
resolveSelectionDragRect,
|
|
13
15
|
shouldEnableSelectionDrag,
|
|
14
16
|
shouldEnableViewerScroll
|
|
15
17
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -6,6 +6,14 @@ import { StyleProp, ViewStyle } from 'react-native';
|
|
|
6
6
|
|
|
7
7
|
interface ViewerProps {
|
|
8
8
|
engine: DocumentEngine;
|
|
9
|
+
/** Maximum page width at fit zoom, in React Native points; pinch zoom may enlarge it. */
|
|
10
|
+
maxPageWidth?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Fit each page's aspect ratio within the measured viewer height at fit zoom.
|
|
13
|
+
* Supported by the React Native compatibility renderer; not applied by the
|
|
14
|
+
* WebView or dedicated Android PDF renderer.
|
|
15
|
+
*/
|
|
16
|
+
fitPageToViewportHeight?: boolean;
|
|
9
17
|
virtualWindowSize?: number;
|
|
10
18
|
maxToRenderPerBatch?: number;
|
|
11
19
|
removeClippedSubviews?: boolean;
|
|
@@ -50,6 +58,8 @@ interface PageRendererProps {
|
|
|
50
58
|
pageAspectRatio?: number;
|
|
51
59
|
PageViewComponent?: PageViewComponentType;
|
|
52
60
|
availableWidth?: number;
|
|
61
|
+
maxPageWidth?: number;
|
|
62
|
+
maxPageHeight?: number;
|
|
53
63
|
pageViewportWidth?: number;
|
|
54
64
|
horizontalPadding?: number;
|
|
55
65
|
spacing?: number;
|
|
@@ -133,8 +143,9 @@ declare function ReadingShell({ engine, title, documentType, thumbsInitialCount,
|
|
|
133
143
|
|
|
134
144
|
type DedicatedAndroidPdfViewerProps = {
|
|
135
145
|
engine: DocumentEngine;
|
|
146
|
+
maxPageWidth?: number;
|
|
136
147
|
};
|
|
137
|
-
declare function DedicatedAndroidPdfViewer({ engine, }: DedicatedAndroidPdfViewerProps): react_jsx_runtime.JSX.Element;
|
|
148
|
+
declare function DedicatedAndroidPdfViewer({ engine, maxPageWidth, }: DedicatedAndroidPdfViewerProps): react_jsx_runtime.JSX.Element;
|
|
138
149
|
|
|
139
150
|
type OverflowSheetProps = {
|
|
140
151
|
visible: boolean;
|
|
@@ -197,6 +208,8 @@ declare const MOBILE_CHROME_METRICS: {
|
|
|
197
208
|
readonly topbarPageButtonSize: 30;
|
|
198
209
|
readonly bottomBarItemPaddingHorizontal: 5;
|
|
199
210
|
readonly bottomBarItemPaddingVertical: 3;
|
|
211
|
+
readonly bottomBarVisualHeight: 52;
|
|
212
|
+
readonly toolDockGap: 12;
|
|
200
213
|
readonly topbarHeight: 56;
|
|
201
214
|
readonly progressGap: 18;
|
|
202
215
|
readonly progressHorizontalOffset: 10;
|
|
@@ -208,5 +221,10 @@ type IconProps = {
|
|
|
208
221
|
strokeWidth?: number;
|
|
209
222
|
};
|
|
210
223
|
declare const IconPageNav: React.FC<IconProps>;
|
|
224
|
+
declare const IconCopy: React.FC<IconProps>;
|
|
225
|
+
declare const IconPencilLine: React.FC<IconProps>;
|
|
226
|
+
declare const IconUnderline: React.FC<IconProps>;
|
|
227
|
+
declare const IconMessageSquareQuote: React.FC<IconProps>;
|
|
228
|
+
declare const IconQuote: React.FC<IconProps>;
|
|
211
229
|
|
|
212
|
-
export { AnnotationEditor, BottomBar, CoverPreview, DocumentActionsSheet, IconPageNav, InfoSheet, MOBILE_CHROME_METRICS, MobilePerfProvider, DedicatedAndroidPdfViewer as NativePdfDocumentViewer, OverflowSheet, _default as PageRenderer, ProgressPill, ReadingShell, RightSheet, SearchOverlay, SearchResultsSheet, SettingsSheet, ToolDock, Topbar, Viewer, createPerfSession, createRunId, useMobilePerf };
|
|
230
|
+
export { AnnotationEditor, BottomBar, CoverPreview, DocumentActionsSheet, IconCopy, IconMessageSquareQuote, IconPageNav, IconPencilLine, IconQuote, IconUnderline, InfoSheet, MOBILE_CHROME_METRICS, MobilePerfProvider, DedicatedAndroidPdfViewer as NativePdfDocumentViewer, OverflowSheet, _default as PageRenderer, ProgressPill, ReadingShell, RightSheet, SearchOverlay, SearchResultsSheet, SettingsSheet, ToolDock, Topbar, Viewer, createPerfSession, createRunId, useMobilePerf };
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,14 @@ import { StyleProp, ViewStyle } from 'react-native';
|
|
|
6
6
|
|
|
7
7
|
interface ViewerProps {
|
|
8
8
|
engine: DocumentEngine;
|
|
9
|
+
/** Maximum page width at fit zoom, in React Native points; pinch zoom may enlarge it. */
|
|
10
|
+
maxPageWidth?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Fit each page's aspect ratio within the measured viewer height at fit zoom.
|
|
13
|
+
* Supported by the React Native compatibility renderer; not applied by the
|
|
14
|
+
* WebView or dedicated Android PDF renderer.
|
|
15
|
+
*/
|
|
16
|
+
fitPageToViewportHeight?: boolean;
|
|
9
17
|
virtualWindowSize?: number;
|
|
10
18
|
maxToRenderPerBatch?: number;
|
|
11
19
|
removeClippedSubviews?: boolean;
|
|
@@ -50,6 +58,8 @@ interface PageRendererProps {
|
|
|
50
58
|
pageAspectRatio?: number;
|
|
51
59
|
PageViewComponent?: PageViewComponentType;
|
|
52
60
|
availableWidth?: number;
|
|
61
|
+
maxPageWidth?: number;
|
|
62
|
+
maxPageHeight?: number;
|
|
53
63
|
pageViewportWidth?: number;
|
|
54
64
|
horizontalPadding?: number;
|
|
55
65
|
spacing?: number;
|
|
@@ -133,8 +143,9 @@ declare function ReadingShell({ engine, title, documentType, thumbsInitialCount,
|
|
|
133
143
|
|
|
134
144
|
type DedicatedAndroidPdfViewerProps = {
|
|
135
145
|
engine: DocumentEngine;
|
|
146
|
+
maxPageWidth?: number;
|
|
136
147
|
};
|
|
137
|
-
declare function DedicatedAndroidPdfViewer({ engine, }: DedicatedAndroidPdfViewerProps): react_jsx_runtime.JSX.Element;
|
|
148
|
+
declare function DedicatedAndroidPdfViewer({ engine, maxPageWidth, }: DedicatedAndroidPdfViewerProps): react_jsx_runtime.JSX.Element;
|
|
138
149
|
|
|
139
150
|
type OverflowSheetProps = {
|
|
140
151
|
visible: boolean;
|
|
@@ -197,6 +208,8 @@ declare const MOBILE_CHROME_METRICS: {
|
|
|
197
208
|
readonly topbarPageButtonSize: 30;
|
|
198
209
|
readonly bottomBarItemPaddingHorizontal: 5;
|
|
199
210
|
readonly bottomBarItemPaddingVertical: 3;
|
|
211
|
+
readonly bottomBarVisualHeight: 52;
|
|
212
|
+
readonly toolDockGap: 12;
|
|
200
213
|
readonly topbarHeight: 56;
|
|
201
214
|
readonly progressGap: 18;
|
|
202
215
|
readonly progressHorizontalOffset: 10;
|
|
@@ -208,5 +221,10 @@ type IconProps = {
|
|
|
208
221
|
strokeWidth?: number;
|
|
209
222
|
};
|
|
210
223
|
declare const IconPageNav: React.FC<IconProps>;
|
|
224
|
+
declare const IconCopy: React.FC<IconProps>;
|
|
225
|
+
declare const IconPencilLine: React.FC<IconProps>;
|
|
226
|
+
declare const IconUnderline: React.FC<IconProps>;
|
|
227
|
+
declare const IconMessageSquareQuote: React.FC<IconProps>;
|
|
228
|
+
declare const IconQuote: React.FC<IconProps>;
|
|
211
229
|
|
|
212
|
-
export { AnnotationEditor, BottomBar, CoverPreview, DocumentActionsSheet, IconPageNav, InfoSheet, MOBILE_CHROME_METRICS, MobilePerfProvider, DedicatedAndroidPdfViewer as NativePdfDocumentViewer, OverflowSheet, _default as PageRenderer, ProgressPill, ReadingShell, RightSheet, SearchOverlay, SearchResultsSheet, SettingsSheet, ToolDock, Topbar, Viewer, createPerfSession, createRunId, useMobilePerf };
|
|
230
|
+
export { AnnotationEditor, BottomBar, CoverPreview, DocumentActionsSheet, IconCopy, IconMessageSquareQuote, IconPageNav, IconPencilLine, IconQuote, IconUnderline, InfoSheet, MOBILE_CHROME_METRICS, MobilePerfProvider, DedicatedAndroidPdfViewer as NativePdfDocumentViewer, OverflowSheet, _default as PageRenderer, ProgressPill, ReadingShell, RightSheet, SearchOverlay, SearchResultsSheet, SettingsSheet, ToolDock, Topbar, Viewer, createPerfSession, createRunId, useMobilePerf };
|