@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
package/dist/index.js
CHANGED
|
@@ -21024,6 +21024,7 @@ __export(ui_react_native_exports, {
|
|
|
21024
21024
|
DocumentActionsSheet: () => DocumentActionsSheet,
|
|
21025
21025
|
InfoSheet: () => InfoSheet,
|
|
21026
21026
|
MOBILE_CHROME_METRICS: () => MOBILE_CHROME_METRICS,
|
|
21027
|
+
NativePdfDocumentViewer: () => DedicatedAndroidPdfViewer,
|
|
21027
21028
|
OverflowSheet: () => OverflowSheet,
|
|
21028
21029
|
PageRenderer: () => PageRenderer_default,
|
|
21029
21030
|
ProgressPill: () => ProgressPill,
|
|
@@ -23949,12 +23950,14 @@ function DedicatedAndroidPdfViewer({
|
|
|
23949
23950
|
const searchResults = (0, import_core3.useViewerStore)((state) => state.searchResults);
|
|
23950
23951
|
const annotations = (0, import_core3.useViewerStore)((state) => state.annotations);
|
|
23951
23952
|
const viewMode = (0, import_core3.useViewerStore)((state) => state.viewMode);
|
|
23953
|
+
const nativeViewMode = viewMode === "single" ? "single" : "continuous";
|
|
23952
23954
|
const setDocumentState = (0, import_core3.useViewerStore)((state) => state.setDocumentState);
|
|
23953
23955
|
const addAnnotation = (0, import_core3.useViewerStore)((state) => state.addAnnotation);
|
|
23954
23956
|
const setSelectedAnnotation = (0, import_core3.useViewerStore)((state) => state.setSelectedAnnotation);
|
|
23955
23957
|
const engineId = getDedicatedAndroidPdfEngineId(engine);
|
|
23956
23958
|
const [selection, setSelection] = (0, import_react3.useState)(null);
|
|
23957
23959
|
const selectionRef = (0, import_react3.useRef)(null);
|
|
23960
|
+
const lastVisiblePagesKeyRef = (0, import_react3.useRef)("");
|
|
23958
23961
|
const lastScrollOffsetYRef = (0, import_react3.useRef)(0);
|
|
23959
23962
|
const scrollDownAccumRef = (0, import_react3.useRef)(0);
|
|
23960
23963
|
const scrollUpAccumRef = (0, import_react3.useRef)(0);
|
|
@@ -24043,7 +24046,7 @@ function DedicatedAndroidPdfViewer({
|
|
|
24043
24046
|
}, []);
|
|
24044
24047
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native3.View, { style: styles3.container, children: [
|
|
24045
24048
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
24046
|
-
import_engine_native2.
|
|
24049
|
+
import_engine_native2.PapyrusPdfDocumentView,
|
|
24047
24050
|
{
|
|
24048
24051
|
style: styles3.viewer,
|
|
24049
24052
|
engineId,
|
|
@@ -24057,13 +24060,30 @@ function DedicatedAndroidPdfViewer({
|
|
|
24057
24060
|
searchResults,
|
|
24058
24061
|
annotations,
|
|
24059
24062
|
selectionActive: !!selection,
|
|
24060
|
-
viewMode,
|
|
24061
|
-
|
|
24063
|
+
viewMode: nativeViewMode,
|
|
24064
|
+
onPageChange: (event) => {
|
|
24062
24065
|
setDocumentState({ currentPage: event.nativeEvent.page });
|
|
24063
24066
|
},
|
|
24064
|
-
|
|
24067
|
+
onZoomChange: (event) => {
|
|
24065
24068
|
setDocumentState({ zoom: event.nativeEvent.zoom });
|
|
24066
24069
|
},
|
|
24070
|
+
onVisiblePagesChange: (event) => {
|
|
24071
|
+
const pages = event.nativeEvent.pages ?? [];
|
|
24072
|
+
const stablePages = pages.filter(
|
|
24073
|
+
(page) => page.visibleRatio >= 0.03
|
|
24074
|
+
);
|
|
24075
|
+
if (stablePages.length === 0) {
|
|
24076
|
+
return;
|
|
24077
|
+
}
|
|
24078
|
+
const key = stablePages.map(
|
|
24079
|
+
(page) => `${page.pageIndex}:${Math.round(page.visibleRatio * 100)}`
|
|
24080
|
+
).join("|");
|
|
24081
|
+
if (key === lastVisiblePagesKeyRef.current) {
|
|
24082
|
+
return;
|
|
24083
|
+
}
|
|
24084
|
+
lastVisiblePagesKeyRef.current = key;
|
|
24085
|
+
setDocumentState({ visiblePages: stablePages });
|
|
24086
|
+
},
|
|
24067
24087
|
onAnnotationCreated: (event) => {
|
|
24068
24088
|
addAnnotation(event.nativeEvent);
|
|
24069
24089
|
},
|
|
@@ -24193,6 +24213,14 @@ var styles3 = import_react_native3.StyleSheet.create({
|
|
|
24193
24213
|
}
|
|
24194
24214
|
});
|
|
24195
24215
|
|
|
24216
|
+
// components/nativePdfViewerMode.ts
|
|
24217
|
+
var shouldUseNativePdfViewer = ({
|
|
24218
|
+
viewerMode,
|
|
24219
|
+
pageCount,
|
|
24220
|
+
isWebView,
|
|
24221
|
+
nativeEngineId
|
|
24222
|
+
}) => viewerMode === "native" && pageCount > 0 && !isWebView && !!nativeEngineId;
|
|
24223
|
+
|
|
24196
24224
|
// components/Viewer.tsx
|
|
24197
24225
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
24198
24226
|
var LIST_TOP_PADDING = 18;
|
|
@@ -24222,7 +24250,8 @@ var Viewer = ({
|
|
|
24222
24250
|
virtualWindowSize,
|
|
24223
24251
|
maxToRenderPerBatch,
|
|
24224
24252
|
removeClippedSubviews,
|
|
24225
|
-
useDedicatedAndroidPdfViewer
|
|
24253
|
+
useDedicatedAndroidPdfViewer,
|
|
24254
|
+
viewerMode
|
|
24226
24255
|
}) => {
|
|
24227
24256
|
const pageCount = (0, import_core4.useViewerStore)((state) => state.pageCount);
|
|
24228
24257
|
const currentPage = (0, import_core4.useViewerStore)((state) => state.currentPage);
|
|
@@ -24236,6 +24265,7 @@ var Viewer = ({
|
|
|
24236
24265
|
const uiTheme = (0, import_core4.useViewerStore)((state) => state.uiTheme);
|
|
24237
24266
|
const viewMode = (0, import_core4.useViewerStore)((state) => state.viewMode);
|
|
24238
24267
|
const zoom = (0, import_core4.useViewerStore)((state) => state.zoom);
|
|
24268
|
+
const storeViewerMode = (0, import_core4.useViewerStore)((state) => state.viewerMode);
|
|
24239
24269
|
const listRef = (0, import_react4.useRef)(null);
|
|
24240
24270
|
const horizontalScrollRef = (0, import_react4.useRef)(null);
|
|
24241
24271
|
const isDark = uiTheme === "dark";
|
|
@@ -24244,7 +24274,14 @@ var Viewer = ({
|
|
|
24244
24274
|
const isSingle = viewMode === "single";
|
|
24245
24275
|
const renderTargetType = engine.getRenderTargetType?.() ?? "canvas";
|
|
24246
24276
|
const isWebView = renderTargetType === "webview";
|
|
24247
|
-
const
|
|
24277
|
+
const resolvedViewerMode = viewerMode ?? (useDedicatedAndroidPdfViewer ? "native" : storeViewerMode);
|
|
24278
|
+
const nativeEngineId = getDedicatedAndroidPdfEngineId(engine);
|
|
24279
|
+
const isNativePdfViewer = shouldUseNativePdfViewer({
|
|
24280
|
+
viewerMode: resolvedViewerMode,
|
|
24281
|
+
pageCount,
|
|
24282
|
+
isWebView,
|
|
24283
|
+
nativeEngineId
|
|
24284
|
+
});
|
|
24248
24285
|
const perfEnabled = isMobilePerfEnabled();
|
|
24249
24286
|
const mountedAtRef = (0, import_react4.useRef)(perfNow());
|
|
24250
24287
|
const readyLoggedRef = (0, import_react4.useRef)(false);
|
|
@@ -25398,7 +25435,7 @@ var Viewer = ({
|
|
|
25398
25435
|
if (isWebView) {
|
|
25399
25436
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native4.View, { style: [styles4.container, isDark && styles4.containerDark], children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(WebViewViewer_default, { engine }) });
|
|
25400
25437
|
}
|
|
25401
|
-
if (
|
|
25438
|
+
if (isNativePdfViewer) {
|
|
25402
25439
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native4.View, { style: [styles4.container, isDark && styles4.containerDark], children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DedicatedAndroidPdfViewer, { engine }) });
|
|
25403
25440
|
}
|
|
25404
25441
|
if (isSingle) {
|
|
@@ -28542,14 +28579,10 @@ var SettingsSheet = ({
|
|
|
28542
28579
|
const isPaged = viewMode === "single";
|
|
28543
28580
|
const isDouble = viewMode === "double";
|
|
28544
28581
|
const t = getStrings(locale);
|
|
28545
|
-
const [hasBeenVisible, setHasBeenVisible] = (0, import_react10.useState)(visible);
|
|
28546
28582
|
const snapPoints = (0, import_react10.useMemo)(
|
|
28547
28583
|
() => [Math.min(640, import_react_native11.Dimensions.get("window").height * 0.72)],
|
|
28548
28584
|
[]
|
|
28549
28585
|
);
|
|
28550
|
-
(0, import_react10.useEffect)(() => {
|
|
28551
|
-
if (visible) setHasBeenVisible(true);
|
|
28552
|
-
}, [visible]);
|
|
28553
28586
|
const renderBackdrop = (0, import_react10.useCallback)(
|
|
28554
28587
|
(props) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
28555
28588
|
import_bottom_sheet2.BottomSheetBackdrop,
|
|
@@ -28588,7 +28621,6 @@ var SettingsSheet = ({
|
|
|
28588
28621
|
engine.setZoom(next);
|
|
28589
28622
|
setDocumentState({ zoom: next });
|
|
28590
28623
|
};
|
|
28591
|
-
if (!hasBeenVisible) return null;
|
|
28592
28624
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native11.View, { style: styles11.modalRoot, pointerEvents: "box-none", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
28593
28625
|
import_bottom_sheet2.default,
|
|
28594
28626
|
{
|
|
@@ -30615,6 +30647,7 @@ var styles19 = import_react_native19.StyleSheet.create({
|
|
|
30615
30647
|
DocumentActionsSheet,
|
|
30616
30648
|
InfoSheet,
|
|
30617
30649
|
MOBILE_CHROME_METRICS,
|
|
30650
|
+
NativePdfDocumentViewer,
|
|
30618
30651
|
OverflowSheet,
|
|
30619
30652
|
PageRenderer,
|
|
30620
30653
|
ProgressPill,
|