@papyrus-sdk/ui-react-native 0.2.18-beta.5 → 0.2.18-beta.7
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 +21 -0
- package/dist/chunk-B36LWZCX.mjs +178 -0
- package/dist/chunk-B36LWZCX.mjs.map +1 -0
- package/dist/chunk-KXNP73MZ.mjs +63 -0
- package/dist/chunk-KXNP73MZ.mjs.map +1 -0
- package/dist/chunk-ZD7AOCMD.mjs +9 -0
- package/dist/chunk-ZD7AOCMD.mjs.map +1 -0
- package/dist/gesture/pinchZoom.d.mts +69 -0
- package/dist/gesture/pinchZoom.d.ts +69 -0
- package/dist/gesture/pinchZoom.js +217 -0
- package/dist/gesture/pinchZoom.js.map +1 -0
- package/dist/gesture/pinchZoom.mjs +40 -0
- package/dist/gesture/pinchZoom.mjs.map +1 -0
- package/dist/gesture/selectionInteraction.d.mts +35 -0
- package/dist/gesture/selectionInteraction.d.ts +35 -0
- package/dist/gesture/selectionInteraction.js +90 -0
- package/dist/gesture/selectionInteraction.js.map +1 -0
- package/dist/gesture/selectionInteraction.mjs +16 -0
- package/dist/gesture/selectionInteraction.mjs.map +1 -0
- package/dist/index.d.mts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +45 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +105 -244
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,217 @@
|
|
|
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
|
+
resolveAnchoredDocumentOffset: () => resolveAnchoredDocumentOffset,
|
|
28
|
+
resolveAnchoredHorizontalSurfaceOffset: () => resolveAnchoredHorizontalSurfaceOffset,
|
|
29
|
+
resolveAnchoredViewportOffset: () => resolveAnchoredViewportOffset,
|
|
30
|
+
resolveCenteredContentInset: () => resolveCenteredContentInset,
|
|
31
|
+
resolveClampedScrollOffset: () => resolveClampedScrollOffset,
|
|
32
|
+
resolveDocumentSurfaceWidth: () => resolveDocumentSurfaceWidth,
|
|
33
|
+
resolveGlobalHorizontalOffset: () => resolveGlobalHorizontalOffset,
|
|
34
|
+
resolvePinchGestureZoom: () => resolvePinchGestureZoom,
|
|
35
|
+
resolvePinchPreviewScale: () => resolvePinchPreviewScale,
|
|
36
|
+
resolvePinchZoomChange: () => resolvePinchZoomChange,
|
|
37
|
+
sanitizePinchPreviewScale: () => sanitizePinchPreviewScale,
|
|
38
|
+
shouldSuppressPressAfterPinch: () => shouldSuppressPressAfterPinch
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(pinchZoom_exports);
|
|
41
|
+
var DEFAULT_PINCH_ZOOM_BOUNDS = {
|
|
42
|
+
minZoom: 0.5,
|
|
43
|
+
maxZoom: 4
|
|
44
|
+
};
|
|
45
|
+
var PINCH_PRESS_SUPPRESSION_MS = 120;
|
|
46
|
+
var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
47
|
+
var getTouchDistance = (touches) => {
|
|
48
|
+
if (touches.length < 2) return 0;
|
|
49
|
+
const [first, second] = touches;
|
|
50
|
+
return Math.hypot(second.pageX - first.pageX, second.pageY - first.pageY);
|
|
51
|
+
};
|
|
52
|
+
var isPinchTouchList = (touches) => touches.length === 2 && getTouchDistance(touches) > 0;
|
|
53
|
+
var createPinchSession = (touches, zoom, bounds = DEFAULT_PINCH_ZOOM_BOUNDS) => ({
|
|
54
|
+
initialDistance: Math.max(1, getTouchDistance(touches)),
|
|
55
|
+
initialZoom: clamp(zoom, bounds.minZoom, bounds.maxZoom)
|
|
56
|
+
});
|
|
57
|
+
var resolvePinchZoomChange = (session, touches, bounds = DEFAULT_PINCH_ZOOM_BOUNDS) => {
|
|
58
|
+
const distance = getTouchDistance(touches);
|
|
59
|
+
if (distance <= 0) {
|
|
60
|
+
return clamp(session.initialZoom, bounds.minZoom, bounds.maxZoom);
|
|
61
|
+
}
|
|
62
|
+
return clamp(
|
|
63
|
+
session.initialZoom * (distance / session.initialDistance),
|
|
64
|
+
bounds.minZoom,
|
|
65
|
+
bounds.maxZoom
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
var resolvePinchPreviewScale = (startZoom, previewZoom) => {
|
|
69
|
+
const safeStartZoom = Math.max(1e-4, Math.abs(startZoom));
|
|
70
|
+
return previewZoom / safeStartZoom;
|
|
71
|
+
};
|
|
72
|
+
var sanitizePinchPreviewScale = (value) => {
|
|
73
|
+
if (!Number.isFinite(value) || value <= 0) {
|
|
74
|
+
return 1;
|
|
75
|
+
}
|
|
76
|
+
return value;
|
|
77
|
+
};
|
|
78
|
+
var resolvePinchGestureZoom = (startZoom, scaleFactor, bounds = DEFAULT_PINCH_ZOOM_BOUNDS) => clamp(
|
|
79
|
+
(Number.isFinite(startZoom) && startZoom > 0 ? startZoom : 1) * (Number.isFinite(scaleFactor) && scaleFactor > 0 ? scaleFactor : 1),
|
|
80
|
+
bounds.minZoom,
|
|
81
|
+
bounds.maxZoom
|
|
82
|
+
);
|
|
83
|
+
var resolveAnchoredViewportOffset = ({
|
|
84
|
+
viewportOffset,
|
|
85
|
+
startScrollOffset,
|
|
86
|
+
startItemOffset,
|
|
87
|
+
startItemLength,
|
|
88
|
+
endItemOffset,
|
|
89
|
+
endItemLength,
|
|
90
|
+
viewportLength,
|
|
91
|
+
endContentLength
|
|
92
|
+
}) => {
|
|
93
|
+
const safeViewportOffset = Number.isFinite(viewportOffset) ? viewportOffset : 0;
|
|
94
|
+
const safeStartScrollOffset = Number.isFinite(startScrollOffset) ? startScrollOffset : 0;
|
|
95
|
+
const safeStartItemOffset = Number.isFinite(startItemOffset) ? startItemOffset : 0;
|
|
96
|
+
const safeStartItemLength = Number.isFinite(startItemLength) && startItemLength > 0 ? startItemLength : 1;
|
|
97
|
+
const safeEndItemOffset = Number.isFinite(endItemOffset) ? endItemOffset : 0;
|
|
98
|
+
const safeEndItemLength = Number.isFinite(endItemLength) && endItemLength > 0 ? endItemLength : 1;
|
|
99
|
+
const safeViewportLength = Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;
|
|
100
|
+
const safeEndContentLength = Number.isFinite(endContentLength) && endContentLength > 0 ? endContentLength : safeEndItemOffset + safeEndItemLength;
|
|
101
|
+
const contentPoint = safeStartScrollOffset + safeViewportOffset - safeStartItemOffset;
|
|
102
|
+
const normalizedPoint = clamp(contentPoint / safeStartItemLength, 0, 1);
|
|
103
|
+
const anchoredContentPoint = safeEndItemOffset + normalizedPoint * safeEndItemLength;
|
|
104
|
+
return clamp(
|
|
105
|
+
anchoredContentPoint - safeViewportOffset,
|
|
106
|
+
0,
|
|
107
|
+
Math.max(0, safeEndContentLength - safeViewportLength)
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
var resolveAnchoredDocumentOffset = ({
|
|
111
|
+
viewportOffset,
|
|
112
|
+
startScrollOffset,
|
|
113
|
+
startContentLength,
|
|
114
|
+
endContentLength,
|
|
115
|
+
viewportLength
|
|
116
|
+
}) => {
|
|
117
|
+
const safeViewportOffset = Number.isFinite(viewportOffset) ? viewportOffset : 0;
|
|
118
|
+
const safeStartScrollOffset = Number.isFinite(startScrollOffset) ? startScrollOffset : 0;
|
|
119
|
+
const safeStartContentLength = Number.isFinite(startContentLength) && startContentLength > 0 ? startContentLength : 1;
|
|
120
|
+
const safeEndContentLength = Number.isFinite(endContentLength) && endContentLength > 0 ? endContentLength : 0;
|
|
121
|
+
const safeViewportLength = Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;
|
|
122
|
+
const anchoredRatio = clamp(
|
|
123
|
+
(safeStartScrollOffset + safeViewportOffset) / safeStartContentLength,
|
|
124
|
+
0,
|
|
125
|
+
1
|
|
126
|
+
);
|
|
127
|
+
return resolveClampedScrollOffset(
|
|
128
|
+
anchoredRatio * safeEndContentLength - safeViewportOffset,
|
|
129
|
+
safeEndContentLength,
|
|
130
|
+
safeViewportLength
|
|
131
|
+
);
|
|
132
|
+
};
|
|
133
|
+
var resolveClampedScrollOffset = (offset, contentLength, viewportLength) => {
|
|
134
|
+
const safeOffset = Number.isFinite(offset) ? offset : 0;
|
|
135
|
+
const safeContentLength = Number.isFinite(contentLength) && contentLength > 0 ? contentLength : 0;
|
|
136
|
+
const safeViewportLength = Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;
|
|
137
|
+
return clamp(
|
|
138
|
+
safeOffset,
|
|
139
|
+
0,
|
|
140
|
+
Math.max(0, safeContentLength - safeViewportLength)
|
|
141
|
+
);
|
|
142
|
+
};
|
|
143
|
+
var resolveDocumentSurfaceWidth = ({
|
|
144
|
+
viewportWidth,
|
|
145
|
+
contentWidth,
|
|
146
|
+
horizontalPadding
|
|
147
|
+
}) => {
|
|
148
|
+
const safeViewportWidth = Number.isFinite(viewportWidth) && viewportWidth > 0 ? viewportWidth : 0;
|
|
149
|
+
const safeContentWidth = Number.isFinite(contentWidth) && contentWidth > 0 ? contentWidth : 0;
|
|
150
|
+
const safeHorizontalPadding = Number.isFinite(horizontalPadding) && horizontalPadding > 0 ? horizontalPadding : 0;
|
|
151
|
+
return Math.max(
|
|
152
|
+
safeViewportWidth,
|
|
153
|
+
safeContentWidth + safeHorizontalPadding * 2
|
|
154
|
+
);
|
|
155
|
+
};
|
|
156
|
+
var resolveGlobalHorizontalOffset = ({
|
|
157
|
+
offsetX,
|
|
158
|
+
surfaceWidth,
|
|
159
|
+
viewportWidth
|
|
160
|
+
}) => resolveClampedScrollOffset(offsetX, surfaceWidth, viewportWidth);
|
|
161
|
+
var resolveAnchoredHorizontalSurfaceOffset = ({
|
|
162
|
+
focalViewportX,
|
|
163
|
+
startSurfaceScrollX,
|
|
164
|
+
startSurfaceWidth,
|
|
165
|
+
endSurfaceWidth,
|
|
166
|
+
viewportWidth
|
|
167
|
+
}) => {
|
|
168
|
+
const safeFocalViewportX = Number.isFinite(focalViewportX) ? focalViewportX : 0;
|
|
169
|
+
const safeStartSurfaceScrollX = Number.isFinite(startSurfaceScrollX) ? startSurfaceScrollX : 0;
|
|
170
|
+
const safeStartSurfaceWidth = Number.isFinite(startSurfaceWidth) && startSurfaceWidth > 0 ? startSurfaceWidth : 1;
|
|
171
|
+
const safeEndSurfaceWidth = Number.isFinite(endSurfaceWidth) && endSurfaceWidth > 0 ? endSurfaceWidth : 0;
|
|
172
|
+
const safeViewportWidth = Number.isFinite(viewportWidth) && viewportWidth > 0 ? viewportWidth : 0;
|
|
173
|
+
const anchoredRatio = clamp(
|
|
174
|
+
(safeStartSurfaceScrollX + safeFocalViewportX) / safeStartSurfaceWidth,
|
|
175
|
+
0,
|
|
176
|
+
1
|
|
177
|
+
);
|
|
178
|
+
return resolveGlobalHorizontalOffset({
|
|
179
|
+
offsetX: anchoredRatio * safeEndSurfaceWidth - safeFocalViewportX,
|
|
180
|
+
surfaceWidth: safeEndSurfaceWidth,
|
|
181
|
+
viewportWidth: safeViewportWidth
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
var resolveCenteredContentInset = ({
|
|
185
|
+
viewportLength,
|
|
186
|
+
contentLength
|
|
187
|
+
}) => {
|
|
188
|
+
const safeViewportLength = Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;
|
|
189
|
+
const safeContentLength = Number.isFinite(contentLength) && contentLength > 0 ? contentLength : 0;
|
|
190
|
+
return Math.max(0, (safeViewportLength - safeContentLength) / 2);
|
|
191
|
+
};
|
|
192
|
+
var shouldSuppressPressAfterPinch = (lastPinchEndedAt, now = Date.now(), windowMs = PINCH_PRESS_SUPPRESSION_MS) => {
|
|
193
|
+
if (typeof lastPinchEndedAt !== "number") return false;
|
|
194
|
+
const elapsedMs = now - lastPinchEndedAt;
|
|
195
|
+
return elapsedMs >= 0 && elapsedMs < windowMs;
|
|
196
|
+
};
|
|
197
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
198
|
+
0 && (module.exports = {
|
|
199
|
+
DEFAULT_PINCH_ZOOM_BOUNDS,
|
|
200
|
+
PINCH_PRESS_SUPPRESSION_MS,
|
|
201
|
+
createPinchSession,
|
|
202
|
+
getTouchDistance,
|
|
203
|
+
isPinchTouchList,
|
|
204
|
+
resolveAnchoredDocumentOffset,
|
|
205
|
+
resolveAnchoredHorizontalSurfaceOffset,
|
|
206
|
+
resolveAnchoredViewportOffset,
|
|
207
|
+
resolveCenteredContentInset,
|
|
208
|
+
resolveClampedScrollOffset,
|
|
209
|
+
resolveDocumentSurfaceWidth,
|
|
210
|
+
resolveGlobalHorizontalOffset,
|
|
211
|
+
resolvePinchGestureZoom,
|
|
212
|
+
resolvePinchPreviewScale,
|
|
213
|
+
resolvePinchZoomChange,
|
|
214
|
+
sanitizePinchPreviewScale,
|
|
215
|
+
shouldSuppressPressAfterPinch
|
|
216
|
+
});
|
|
217
|
+
//# 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 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;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,O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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":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_PINCH_ZOOM_BOUNDS,
|
|
3
|
+
PINCH_PRESS_SUPPRESSION_MS,
|
|
4
|
+
createPinchSession,
|
|
5
|
+
getTouchDistance,
|
|
6
|
+
isPinchTouchList,
|
|
7
|
+
resolveAnchoredDocumentOffset,
|
|
8
|
+
resolveAnchoredHorizontalSurfaceOffset,
|
|
9
|
+
resolveAnchoredViewportOffset,
|
|
10
|
+
resolveCenteredContentInset,
|
|
11
|
+
resolveClampedScrollOffset,
|
|
12
|
+
resolveDocumentSurfaceWidth,
|
|
13
|
+
resolveGlobalHorizontalOffset,
|
|
14
|
+
resolvePinchGestureZoom,
|
|
15
|
+
resolvePinchPreviewScale,
|
|
16
|
+
resolvePinchZoomChange,
|
|
17
|
+
sanitizePinchPreviewScale,
|
|
18
|
+
shouldSuppressPressAfterPinch
|
|
19
|
+
} from "../chunk-B36LWZCX.mjs";
|
|
20
|
+
import "../chunk-ZD7AOCMD.mjs";
|
|
21
|
+
export {
|
|
22
|
+
DEFAULT_PINCH_ZOOM_BOUNDS,
|
|
23
|
+
PINCH_PRESS_SUPPRESSION_MS,
|
|
24
|
+
createPinchSession,
|
|
25
|
+
getTouchDistance,
|
|
26
|
+
isPinchTouchList,
|
|
27
|
+
resolveAnchoredDocumentOffset,
|
|
28
|
+
resolveAnchoredHorizontalSurfaceOffset,
|
|
29
|
+
resolveAnchoredViewportOffset,
|
|
30
|
+
resolveCenteredContentInset,
|
|
31
|
+
resolveClampedScrollOffset,
|
|
32
|
+
resolveDocumentSurfaceWidth,
|
|
33
|
+
resolveGlobalHorizontalOffset,
|
|
34
|
+
resolvePinchGestureZoom,
|
|
35
|
+
resolvePinchPreviewScale,
|
|
36
|
+
resolvePinchZoomChange,
|
|
37
|
+
sanitizePinchPreviewScale,
|
|
38
|
+
shouldSuppressPressAfterPinch
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=pinchZoom.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
type ViewerScrollState = {
|
|
2
|
+
selectionDragActive: boolean;
|
|
3
|
+
gestureScrollLockActive?: boolean;
|
|
4
|
+
};
|
|
5
|
+
type SelectionGestureTool = "select" | "highlight" | "underline" | "squiggly" | "strikeout" | "text" | "comment" | "ink";
|
|
6
|
+
type SelectionInteractionMode = "pan" | "select";
|
|
7
|
+
type SelectionGestureActivationInput = {
|
|
8
|
+
activeTool: SelectionGestureTool;
|
|
9
|
+
interactionMode: SelectionInteractionMode;
|
|
10
|
+
};
|
|
11
|
+
type ToolDockSelectionState = SelectionGestureActivationInput & {
|
|
12
|
+
toolId: SelectionGestureTool;
|
|
13
|
+
};
|
|
14
|
+
type ToolDockDismissState = SelectionGestureActivationInput & {
|
|
15
|
+
toolDockOpen: boolean;
|
|
16
|
+
};
|
|
17
|
+
type SelectionEdgeAutoscrollInput = {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
threshold: number;
|
|
23
|
+
maxStep: number;
|
|
24
|
+
};
|
|
25
|
+
type SelectionEdgeAutoscroll = {
|
|
26
|
+
dx: number;
|
|
27
|
+
dy: number;
|
|
28
|
+
};
|
|
29
|
+
declare const shouldEnableViewerScroll: ({ selectionDragActive, gestureScrollLockActive, }: ViewerScrollState) => boolean;
|
|
30
|
+
declare const shouldEnableSelectionDrag: ({ activeTool, interactionMode, }: SelectionGestureActivationInput) => boolean;
|
|
31
|
+
declare const isToolDockToolSelected: ({ activeTool, interactionMode, toolId, }: ToolDockSelectionState) => boolean;
|
|
32
|
+
declare const getToolDockDismissState: ({ activeTool: _activeTool, interactionMode: _interactionMode, }: SelectionGestureActivationInput) => ToolDockDismissState;
|
|
33
|
+
declare const getSelectionEdgeAutoscroll: ({ x, y, width, height, threshold, maxStep, }: SelectionEdgeAutoscrollInput) => SelectionEdgeAutoscroll;
|
|
34
|
+
|
|
35
|
+
export { type SelectionEdgeAutoscroll, type SelectionEdgeAutoscrollInput, type SelectionGestureActivationInput, type SelectionGestureTool, type SelectionInteractionMode, type ToolDockDismissState, type ToolDockSelectionState, type ViewerScrollState, getSelectionEdgeAutoscroll, getToolDockDismissState, isToolDockToolSelected, shouldEnableSelectionDrag, shouldEnableViewerScroll };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
type ViewerScrollState = {
|
|
2
|
+
selectionDragActive: boolean;
|
|
3
|
+
gestureScrollLockActive?: boolean;
|
|
4
|
+
};
|
|
5
|
+
type SelectionGestureTool = "select" | "highlight" | "underline" | "squiggly" | "strikeout" | "text" | "comment" | "ink";
|
|
6
|
+
type SelectionInteractionMode = "pan" | "select";
|
|
7
|
+
type SelectionGestureActivationInput = {
|
|
8
|
+
activeTool: SelectionGestureTool;
|
|
9
|
+
interactionMode: SelectionInteractionMode;
|
|
10
|
+
};
|
|
11
|
+
type ToolDockSelectionState = SelectionGestureActivationInput & {
|
|
12
|
+
toolId: SelectionGestureTool;
|
|
13
|
+
};
|
|
14
|
+
type ToolDockDismissState = SelectionGestureActivationInput & {
|
|
15
|
+
toolDockOpen: boolean;
|
|
16
|
+
};
|
|
17
|
+
type SelectionEdgeAutoscrollInput = {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
threshold: number;
|
|
23
|
+
maxStep: number;
|
|
24
|
+
};
|
|
25
|
+
type SelectionEdgeAutoscroll = {
|
|
26
|
+
dx: number;
|
|
27
|
+
dy: number;
|
|
28
|
+
};
|
|
29
|
+
declare const shouldEnableViewerScroll: ({ selectionDragActive, gestureScrollLockActive, }: ViewerScrollState) => boolean;
|
|
30
|
+
declare const shouldEnableSelectionDrag: ({ activeTool, interactionMode, }: SelectionGestureActivationInput) => boolean;
|
|
31
|
+
declare const isToolDockToolSelected: ({ activeTool, interactionMode, toolId, }: ToolDockSelectionState) => boolean;
|
|
32
|
+
declare const getToolDockDismissState: ({ activeTool: _activeTool, interactionMode: _interactionMode, }: SelectionGestureActivationInput) => ToolDockDismissState;
|
|
33
|
+
declare const getSelectionEdgeAutoscroll: ({ x, y, width, height, threshold, maxStep, }: SelectionEdgeAutoscrollInput) => SelectionEdgeAutoscroll;
|
|
34
|
+
|
|
35
|
+
export { type SelectionEdgeAutoscroll, type SelectionEdgeAutoscrollInput, type SelectionGestureActivationInput, type SelectionGestureTool, type SelectionInteractionMode, type ToolDockDismissState, type ToolDockSelectionState, type ViewerScrollState, getSelectionEdgeAutoscroll, getToolDockDismissState, isToolDockToolSelected, shouldEnableSelectionDrag, shouldEnableViewerScroll };
|
|
@@ -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: _activeTool,
|
|
65
|
+
interactionMode: _interactionMode
|
|
66
|
+
}) => ({
|
|
67
|
+
toolDockOpen: false,
|
|
68
|
+
activeTool: "select",
|
|
69
|
+
interactionMode: "pan"
|
|
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: _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;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,YAAY;AAAA,EACZ,iBAAiB;AACnB,OAA8D;AAAA,EAC5D,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,iBAAiB;AACnB;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-KXNP73MZ.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,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { DocumentEngine, DocumentType, MobilePrimaryDestination, DocumentSource } from '@papyrus-sdk/types';
|
|
2
|
+
import { DocumentEngine, PdfViewerMode, DocumentType, MobilePrimaryDestination, DocumentSource } from '@papyrus-sdk/types';
|
|
3
3
|
import { PapyrusPageViewProps } from '@papyrus-sdk/engine-native';
|
|
4
4
|
import { StyleProp, ViewStyle } from 'react-native';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -10,6 +10,7 @@ interface ViewerProps {
|
|
|
10
10
|
maxToRenderPerBatch?: number;
|
|
11
11
|
removeClippedSubviews?: boolean;
|
|
12
12
|
useDedicatedAndroidPdfViewer?: boolean;
|
|
13
|
+
viewerMode?: PdfViewerMode;
|
|
13
14
|
}
|
|
14
15
|
declare const Viewer: React.FC<ViewerProps>;
|
|
15
16
|
|
|
@@ -98,6 +99,11 @@ type ReadingShellProps = {
|
|
|
98
99
|
};
|
|
99
100
|
declare function ReadingShell({ engine, title, documentType, thumbsInitialCount, viewerProps, }: ReadingShellProps): react_jsx_runtime.JSX.Element;
|
|
100
101
|
|
|
102
|
+
type DedicatedAndroidPdfViewerProps = {
|
|
103
|
+
engine: DocumentEngine;
|
|
104
|
+
};
|
|
105
|
+
declare function DedicatedAndroidPdfViewer({ engine, }: DedicatedAndroidPdfViewerProps): react_jsx_runtime.JSX.Element;
|
|
106
|
+
|
|
101
107
|
type OverflowSheetProps = {
|
|
102
108
|
visible: boolean;
|
|
103
109
|
onClose: () => void;
|
|
@@ -159,4 +165,4 @@ declare const MOBILE_CHROME_METRICS: {
|
|
|
159
165
|
readonly bottomBarItemPaddingVertical: 3;
|
|
160
166
|
};
|
|
161
167
|
|
|
162
|
-
export { AnnotationEditor, BottomBar, CoverPreview, DocumentActionsSheet, InfoSheet, MOBILE_CHROME_METRICS, OverflowSheet, _default as PageRenderer, ProgressPill, ReadingShell, RightSheet, SearchOverlay, SearchResultsSheet, SettingsSheet, ToolDock, Topbar, Viewer };
|
|
168
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { DocumentEngine, DocumentType, MobilePrimaryDestination, DocumentSource } from '@papyrus-sdk/types';
|
|
2
|
+
import { DocumentEngine, PdfViewerMode, DocumentType, MobilePrimaryDestination, DocumentSource } from '@papyrus-sdk/types';
|
|
3
3
|
import { PapyrusPageViewProps } from '@papyrus-sdk/engine-native';
|
|
4
4
|
import { StyleProp, ViewStyle } from 'react-native';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -10,6 +10,7 @@ interface ViewerProps {
|
|
|
10
10
|
maxToRenderPerBatch?: number;
|
|
11
11
|
removeClippedSubviews?: boolean;
|
|
12
12
|
useDedicatedAndroidPdfViewer?: boolean;
|
|
13
|
+
viewerMode?: PdfViewerMode;
|
|
13
14
|
}
|
|
14
15
|
declare const Viewer: React.FC<ViewerProps>;
|
|
15
16
|
|
|
@@ -98,6 +99,11 @@ type ReadingShellProps = {
|
|
|
98
99
|
};
|
|
99
100
|
declare function ReadingShell({ engine, title, documentType, thumbsInitialCount, viewerProps, }: ReadingShellProps): react_jsx_runtime.JSX.Element;
|
|
100
101
|
|
|
102
|
+
type DedicatedAndroidPdfViewerProps = {
|
|
103
|
+
engine: DocumentEngine;
|
|
104
|
+
};
|
|
105
|
+
declare function DedicatedAndroidPdfViewer({ engine, }: DedicatedAndroidPdfViewerProps): react_jsx_runtime.JSX.Element;
|
|
106
|
+
|
|
101
107
|
type OverflowSheetProps = {
|
|
102
108
|
visible: boolean;
|
|
103
109
|
onClose: () => void;
|
|
@@ -159,4 +165,4 @@ declare const MOBILE_CHROME_METRICS: {
|
|
|
159
165
|
readonly bottomBarItemPaddingVertical: 3;
|
|
160
166
|
};
|
|
161
167
|
|
|
162
|
-
export { AnnotationEditor, BottomBar, CoverPreview, DocumentActionsSheet, InfoSheet, MOBILE_CHROME_METRICS, OverflowSheet, _default as PageRenderer, ProgressPill, ReadingShell, RightSheet, SearchOverlay, SearchResultsSheet, SettingsSheet, ToolDock, Topbar, Viewer };
|
|
168
|
+
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 };
|