@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/dist/index.mjs CHANGED
@@ -1,7 +1,25 @@
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
- };
1
+ import {
2
+ DEFAULT_PINCH_ZOOM_BOUNDS,
3
+ resolveAnchoredDocumentOffset,
4
+ resolveAnchoredHorizontalSurfaceOffset,
5
+ resolveAnchoredViewportOffset,
6
+ resolveCenteredContentInset,
7
+ resolveDocumentSurfaceWidth,
8
+ resolveGlobalHorizontalOffset,
9
+ resolvePinchGestureZoom,
10
+ sanitizePinchPreviewScale,
11
+ shouldSuppressPressAfterPinch
12
+ } from "./chunk-B36LWZCX.mjs";
13
+ import {
14
+ getSelectionEdgeAutoscroll,
15
+ getToolDockDismissState,
16
+ isToolDockToolSelected,
17
+ shouldEnableSelectionDrag,
18
+ shouldEnableViewerScroll
19
+ } from "./chunk-KXNP73MZ.mjs";
20
+ import {
21
+ __commonJS
22
+ } from "./chunk-ZD7AOCMD.mjs";
5
23
 
6
24
  // runtime/index.html
7
25
  var require_runtime = __commonJS({
@@ -20999,7 +21017,6 @@ import {
20999
21017
  } from "react";
21000
21018
  import {
21001
21019
  FlatList,
21002
- Platform as Platform2,
21003
21020
  ScrollView,
21004
21021
  StyleSheet as StyleSheet4,
21005
21022
  View as View4,
@@ -21215,194 +21232,6 @@ var createScrollPerfMonitor = (scope, label = "scroll") => {
21215
21232
  };
21216
21233
  var logPerfEvent = logPerf;
21217
21234
 
21218
- // gesture/pinchZoom.ts
21219
- var DEFAULT_PINCH_ZOOM_BOUNDS = {
21220
- minZoom: 0.5,
21221
- maxZoom: 4
21222
- };
21223
- var PINCH_PRESS_SUPPRESSION_MS = 120;
21224
- var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
21225
- var sanitizePinchPreviewScale = (value) => {
21226
- if (!Number.isFinite(value) || value <= 0) {
21227
- return 1;
21228
- }
21229
- return value;
21230
- };
21231
- var resolvePinchGestureZoom = (startZoom, scaleFactor, bounds = DEFAULT_PINCH_ZOOM_BOUNDS) => clamp(
21232
- (Number.isFinite(startZoom) && startZoom > 0 ? startZoom : 1) * (Number.isFinite(scaleFactor) && scaleFactor > 0 ? scaleFactor : 1),
21233
- bounds.minZoom,
21234
- bounds.maxZoom
21235
- );
21236
- var resolveAnchoredViewportOffset = ({
21237
- viewportOffset,
21238
- startScrollOffset,
21239
- startItemOffset,
21240
- startItemLength,
21241
- endItemOffset,
21242
- endItemLength,
21243
- viewportLength,
21244
- endContentLength
21245
- }) => {
21246
- const safeViewportOffset = Number.isFinite(viewportOffset) ? viewportOffset : 0;
21247
- const safeStartScrollOffset = Number.isFinite(startScrollOffset) ? startScrollOffset : 0;
21248
- const safeStartItemOffset = Number.isFinite(startItemOffset) ? startItemOffset : 0;
21249
- const safeStartItemLength = Number.isFinite(startItemLength) && startItemLength > 0 ? startItemLength : 1;
21250
- const safeEndItemOffset = Number.isFinite(endItemOffset) ? endItemOffset : 0;
21251
- const safeEndItemLength = Number.isFinite(endItemLength) && endItemLength > 0 ? endItemLength : 1;
21252
- const safeViewportLength = Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;
21253
- const safeEndContentLength = Number.isFinite(endContentLength) && endContentLength > 0 ? endContentLength : safeEndItemOffset + safeEndItemLength;
21254
- const contentPoint = safeStartScrollOffset + safeViewportOffset - safeStartItemOffset;
21255
- const normalizedPoint = clamp(contentPoint / safeStartItemLength, 0, 1);
21256
- const anchoredContentPoint = safeEndItemOffset + normalizedPoint * safeEndItemLength;
21257
- return clamp(
21258
- anchoredContentPoint - safeViewportOffset,
21259
- 0,
21260
- Math.max(0, safeEndContentLength - safeViewportLength)
21261
- );
21262
- };
21263
- var resolveAnchoredDocumentOffset = ({
21264
- viewportOffset,
21265
- startScrollOffset,
21266
- startContentLength,
21267
- endContentLength,
21268
- viewportLength
21269
- }) => {
21270
- const safeViewportOffset = Number.isFinite(viewportOffset) ? viewportOffset : 0;
21271
- const safeStartScrollOffset = Number.isFinite(startScrollOffset) ? startScrollOffset : 0;
21272
- const safeStartContentLength = Number.isFinite(startContentLength) && startContentLength > 0 ? startContentLength : 1;
21273
- const safeEndContentLength = Number.isFinite(endContentLength) && endContentLength > 0 ? endContentLength : 0;
21274
- const safeViewportLength = Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;
21275
- const anchoredRatio = clamp(
21276
- (safeStartScrollOffset + safeViewportOffset) / safeStartContentLength,
21277
- 0,
21278
- 1
21279
- );
21280
- return resolveClampedScrollOffset(
21281
- anchoredRatio * safeEndContentLength - safeViewportOffset,
21282
- safeEndContentLength,
21283
- safeViewportLength
21284
- );
21285
- };
21286
- var resolveClampedScrollOffset = (offset, contentLength, viewportLength) => {
21287
- const safeOffset = Number.isFinite(offset) ? offset : 0;
21288
- const safeContentLength = Number.isFinite(contentLength) && contentLength > 0 ? contentLength : 0;
21289
- const safeViewportLength = Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;
21290
- return clamp(
21291
- safeOffset,
21292
- 0,
21293
- Math.max(0, safeContentLength - safeViewportLength)
21294
- );
21295
- };
21296
- var resolveDocumentSurfaceWidth = ({
21297
- viewportWidth,
21298
- contentWidth,
21299
- horizontalPadding
21300
- }) => {
21301
- const safeViewportWidth = Number.isFinite(viewportWidth) && viewportWidth > 0 ? viewportWidth : 0;
21302
- const safeContentWidth = Number.isFinite(contentWidth) && contentWidth > 0 ? contentWidth : 0;
21303
- const safeHorizontalPadding = Number.isFinite(horizontalPadding) && horizontalPadding > 0 ? horizontalPadding : 0;
21304
- return Math.max(
21305
- safeViewportWidth,
21306
- safeContentWidth + safeHorizontalPadding * 2
21307
- );
21308
- };
21309
- var resolveGlobalHorizontalOffset = ({
21310
- offsetX,
21311
- surfaceWidth,
21312
- viewportWidth
21313
- }) => resolveClampedScrollOffset(offsetX, surfaceWidth, viewportWidth);
21314
- var resolveAnchoredHorizontalSurfaceOffset = ({
21315
- focalViewportX,
21316
- startSurfaceScrollX,
21317
- startSurfaceWidth,
21318
- endSurfaceWidth,
21319
- viewportWidth
21320
- }) => {
21321
- const safeFocalViewportX = Number.isFinite(focalViewportX) ? focalViewportX : 0;
21322
- const safeStartSurfaceScrollX = Number.isFinite(startSurfaceScrollX) ? startSurfaceScrollX : 0;
21323
- const safeStartSurfaceWidth = Number.isFinite(startSurfaceWidth) && startSurfaceWidth > 0 ? startSurfaceWidth : 1;
21324
- const safeEndSurfaceWidth = Number.isFinite(endSurfaceWidth) && endSurfaceWidth > 0 ? endSurfaceWidth : 0;
21325
- const safeViewportWidth = Number.isFinite(viewportWidth) && viewportWidth > 0 ? viewportWidth : 0;
21326
- const anchoredRatio = clamp(
21327
- (safeStartSurfaceScrollX + safeFocalViewportX) / safeStartSurfaceWidth,
21328
- 0,
21329
- 1
21330
- );
21331
- return resolveGlobalHorizontalOffset({
21332
- offsetX: anchoredRatio * safeEndSurfaceWidth - safeFocalViewportX,
21333
- surfaceWidth: safeEndSurfaceWidth,
21334
- viewportWidth: safeViewportWidth
21335
- });
21336
- };
21337
- var resolveCenteredContentInset = ({
21338
- viewportLength,
21339
- contentLength
21340
- }) => {
21341
- const safeViewportLength = Number.isFinite(viewportLength) && viewportLength > 0 ? viewportLength : 0;
21342
- const safeContentLength = Number.isFinite(contentLength) && contentLength > 0 ? contentLength : 0;
21343
- return Math.max(0, (safeViewportLength - safeContentLength) / 2);
21344
- };
21345
- var shouldSuppressPressAfterPinch = (lastPinchEndedAt, now = Date.now(), windowMs = PINCH_PRESS_SUPPRESSION_MS) => {
21346
- if (typeof lastPinchEndedAt !== "number") return false;
21347
- const elapsedMs = now - lastPinchEndedAt;
21348
- return elapsedMs >= 0 && elapsedMs < windowMs;
21349
- };
21350
-
21351
- // gesture/selectionInteraction.ts
21352
- var clamp2 = (value, min, max) => Math.min(max, Math.max(min, value));
21353
- var DRAG_SELECTION_TOOLS = /* @__PURE__ */ new Set([
21354
- "highlight",
21355
- "underline",
21356
- "squiggly",
21357
- "strikeout"
21358
- ]);
21359
- var resolveAxisAutoscroll = (coordinate, size, threshold, maxStep) => {
21360
- if (size <= 0 || threshold <= 0 || maxStep <= 0) return 0;
21361
- const startDistance = clamp2(coordinate, 0, size);
21362
- if (startDistance < threshold) {
21363
- const intensity = 1 - startDistance / threshold;
21364
- return -Math.round(maxStep * intensity);
21365
- }
21366
- const endDistance = clamp2(size - coordinate, 0, size);
21367
- if (endDistance < threshold) {
21368
- const intensity = 1 - endDistance / threshold;
21369
- return Math.round(maxStep * intensity);
21370
- }
21371
- return 0;
21372
- };
21373
- var shouldEnableViewerScroll = ({
21374
- selectionDragActive,
21375
- gestureScrollLockActive = false
21376
- }) => !selectionDragActive && !gestureScrollLockActive;
21377
- var shouldEnableSelectionDrag = ({
21378
- activeTool,
21379
- interactionMode
21380
- }) => DRAG_SELECTION_TOOLS.has(activeTool) || activeTool === "select" && interactionMode === "select";
21381
- var isToolDockToolSelected = ({
21382
- activeTool,
21383
- interactionMode,
21384
- toolId
21385
- }) => toolId === "select" ? activeTool === "select" && interactionMode === "select" : activeTool === toolId;
21386
- var getToolDockDismissState = ({
21387
- activeTool: _activeTool,
21388
- interactionMode: _interactionMode
21389
- }) => ({
21390
- toolDockOpen: false,
21391
- activeTool: "select",
21392
- interactionMode: "pan"
21393
- });
21394
- var getSelectionEdgeAutoscroll = ({
21395
- x,
21396
- y,
21397
- width,
21398
- height,
21399
- threshold,
21400
- maxStep
21401
- }) => ({
21402
- dx: resolveAxisAutoscroll(x, width, threshold, maxStep),
21403
- dy: resolveAxisAutoscroll(y, height, threshold, maxStep)
21404
- });
21405
-
21406
21235
  // viewport/pdfViewportController.ts
21407
21236
  var resolvePdfVerticalAnchorMode = ({
21408
21237
  focalY,
@@ -21802,7 +21631,7 @@ var PageRenderer = ({
21802
21631
  },
21803
21632
  [addAnnotation, annotationColor, logSelectionPerf, pageIndex]
21804
21633
  );
21805
- const clamp3 = (value, min, max) => Math.min(max, Math.max(min, value));
21634
+ const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
21806
21635
  const getBoundsFromRects = (rects) => {
21807
21636
  let minX = 1;
21808
21637
  let minY = 1;
@@ -21816,10 +21645,10 @@ var PageRenderer = ({
21816
21645
  });
21817
21646
  if (maxX <= minX || maxY <= minY) return null;
21818
21647
  return {
21819
- x: clamp3(minX, 0, 1),
21820
- y: clamp3(minY, 0, 1),
21821
- width: clamp3(maxX - minX, 0, 1),
21822
- height: clamp3(maxY - minY, 0, 1)
21648
+ x: clamp(minX, 0, 1),
21649
+ y: clamp(minY, 0, 1),
21650
+ width: clamp(maxX - minX, 0, 1),
21651
+ height: clamp(maxY - minY, 0, 1)
21823
21652
  };
21824
21653
  };
21825
21654
  useEffect(() => {
@@ -21936,8 +21765,8 @@ var PageRenderer = ({
21936
21765
  if (!layout.width || !layout.height) return;
21937
21766
  const size = 26;
21938
21767
  const half = size / 2;
21939
- const left = clamp3(x - half, 0, Math.max(0, layout.width - size));
21940
- const top = clamp3(y - half, 0, Math.max(0, layout.height - size));
21768
+ const left = clamp(x - half, 0, Math.max(0, layout.width - size));
21769
+ const top = clamp(y - half, 0, Math.max(0, layout.height - size));
21941
21770
  const bounds = {
21942
21771
  x: left / layout.width,
21943
21772
  y: top / layout.height,
@@ -21986,7 +21815,7 @@ var PageRenderer = ({
21986
21815
  return;
21987
21816
  }
21988
21817
  const nextX = point.x;
21989
- const nextY = clamp3(point.y + appliedDy, 0, layout.height);
21818
+ const nextY = clamp(point.y + appliedDy, 0, layout.height);
21990
21819
  selectionDragPointRef.current = {
21991
21820
  absoluteY: point.absoluteY,
21992
21821
  x: nextX,
@@ -22013,8 +21842,8 @@ var PageRenderer = ({
22013
21842
  return;
22014
21843
  }
22015
21844
  const start = {
22016
- x: clamp3(x, 0, layout.width),
22017
- y: clamp3(y, 0, layout.height)
21845
+ x: clamp(x, 0, layout.width),
21846
+ y: clamp(y, 0, layout.height)
22018
21847
  };
22019
21848
  selectionStart.current = start;
22020
21849
  selectionDragPointRef.current = { absoluteY, ...start };
@@ -22036,8 +21865,8 @@ var PageRenderer = ({
22036
21865
  const updateSelectionDrag = useCallback(
22037
21866
  (x, y, absoluteY) => {
22038
21867
  if (!selectionEnabled || !selectionStart.current) return;
22039
- const nextX = clamp3(x, 0, layout.width);
22040
- const nextY = clamp3(y, 0, layout.height);
21868
+ const nextX = clamp(x, 0, layout.width);
21869
+ const nextY = clamp(y, 0, layout.height);
22041
21870
  selectionDragPointRef.current = {
22042
21871
  absoluteY,
22043
21872
  x: nextX,
@@ -22362,8 +22191,8 @@ var PageRenderer = ({
22362
22191
  const minSize = 0.01;
22363
22192
  let next = { ...start };
22364
22193
  if (handle === "start") {
22365
- const newX = clamp3(start.x + dx, 0, start.x + start.width - minSize);
22366
- const newY = clamp3(start.y + dy, 0, start.y + start.height - minSize);
22194
+ const newX = clamp(start.x + dx, 0, start.x + start.width - minSize);
22195
+ const newY = clamp(start.y + dy, 0, start.y + start.height - minSize);
22367
22196
  next = {
22368
22197
  x: newX,
22369
22198
  y: newY,
@@ -22371,8 +22200,8 @@ var PageRenderer = ({
22371
22200
  height: start.y + start.height - newY
22372
22201
  };
22373
22202
  } else {
22374
- const maxX = clamp3(start.x + start.width + dx, start.x + minSize, 1);
22375
- const maxY = clamp3(start.y + start.height + dy, start.y + minSize, 1);
22203
+ const maxX = clamp(start.x + start.width + dx, start.x + minSize, 1);
22204
+ const maxY = clamp(start.y + start.height + dy, start.y + minSize, 1);
22376
22205
  next = {
22377
22206
  x: start.x,
22378
22207
  y: start.y,
@@ -23301,7 +23130,7 @@ var WebViewViewer_default = WebViewViewer;
23301
23130
  import { useCallback as useCallback2, useEffect as useEffect3, useRef as useRef3, useState as useState2 } from "react";
23302
23131
  import { Pressable as Pressable2, StyleSheet as StyleSheet3, View as View3 } from "react-native";
23303
23132
  import { useViewerStore as useViewerStore3 } from "@papyrus-sdk/core";
23304
- import { PapyrusPdfViewerView } from "@papyrus-sdk/engine-native";
23133
+ import { PapyrusPdfDocumentView } from "@papyrus-sdk/engine-native";
23305
23134
 
23306
23135
  // icons.tsx
23307
23136
  import Svg2, {
@@ -23939,12 +23768,14 @@ function DedicatedAndroidPdfViewer({
23939
23768
  const searchResults = useViewerStore3((state) => state.searchResults);
23940
23769
  const annotations = useViewerStore3((state) => state.annotations);
23941
23770
  const viewMode = useViewerStore3((state) => state.viewMode);
23771
+ const nativeViewMode = viewMode === "single" ? "single" : "continuous";
23942
23772
  const setDocumentState = useViewerStore3((state) => state.setDocumentState);
23943
23773
  const addAnnotation = useViewerStore3((state) => state.addAnnotation);
23944
23774
  const setSelectedAnnotation = useViewerStore3((state) => state.setSelectedAnnotation);
23945
23775
  const engineId = getDedicatedAndroidPdfEngineId(engine);
23946
23776
  const [selection, setSelection] = useState2(null);
23947
23777
  const selectionRef = useRef3(null);
23778
+ const lastVisiblePagesKeyRef = useRef3("");
23948
23779
  const lastScrollOffsetYRef = useRef3(0);
23949
23780
  const scrollDownAccumRef = useRef3(0);
23950
23781
  const scrollUpAccumRef = useRef3(0);
@@ -24033,7 +23864,7 @@ function DedicatedAndroidPdfViewer({
24033
23864
  }, []);
24034
23865
  return /* @__PURE__ */ jsxs4(View3, { style: styles3.container, children: [
24035
23866
  /* @__PURE__ */ jsx4(
24036
- PapyrusPdfViewerView,
23867
+ PapyrusPdfDocumentView,
24037
23868
  {
24038
23869
  style: styles3.viewer,
24039
23870
  engineId,
@@ -24047,13 +23878,30 @@ function DedicatedAndroidPdfViewer({
24047
23878
  searchResults,
24048
23879
  annotations,
24049
23880
  selectionActive: !!selection,
24050
- viewMode,
24051
- onPageChanged: (event) => {
23881
+ viewMode: nativeViewMode,
23882
+ onPageChange: (event) => {
24052
23883
  setDocumentState({ currentPage: event.nativeEvent.page });
24053
23884
  },
24054
- onZoomChanged: (event) => {
23885
+ onZoomChange: (event) => {
24055
23886
  setDocumentState({ zoom: event.nativeEvent.zoom });
24056
23887
  },
23888
+ onVisiblePagesChange: (event) => {
23889
+ const pages = event.nativeEvent.pages ?? [];
23890
+ const stablePages = pages.filter(
23891
+ (page) => page.visibleRatio >= 0.03
23892
+ );
23893
+ if (stablePages.length === 0) {
23894
+ return;
23895
+ }
23896
+ const key = stablePages.map(
23897
+ (page) => `${page.pageIndex}:${Math.round(page.visibleRatio * 100)}`
23898
+ ).join("|");
23899
+ if (key === lastVisiblePagesKeyRef.current) {
23900
+ return;
23901
+ }
23902
+ lastVisiblePagesKeyRef.current = key;
23903
+ setDocumentState({ visiblePages: stablePages });
23904
+ },
24057
23905
  onAnnotationCreated: (event) => {
24058
23906
  addAnnotation(event.nativeEvent);
24059
23907
  },
@@ -24183,6 +24031,14 @@ var styles3 = StyleSheet3.create({
24183
24031
  }
24184
24032
  });
24185
24033
 
24034
+ // components/nativePdfViewerMode.ts
24035
+ var shouldUseNativePdfViewer = ({
24036
+ viewerMode,
24037
+ pageCount,
24038
+ isWebView,
24039
+ nativeEngineId
24040
+ }) => viewerMode === "native" && pageCount > 0 && !isWebView && !!nativeEngineId;
24041
+
24186
24042
  // components/Viewer.tsx
24187
24043
  import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
24188
24044
  var LIST_TOP_PADDING = 18;
@@ -24212,7 +24068,8 @@ var Viewer = ({
24212
24068
  virtualWindowSize,
24213
24069
  maxToRenderPerBatch,
24214
24070
  removeClippedSubviews,
24215
- useDedicatedAndroidPdfViewer
24071
+ useDedicatedAndroidPdfViewer,
24072
+ viewerMode
24216
24073
  }) => {
24217
24074
  const pageCount = useViewerStore4((state) => state.pageCount);
24218
24075
  const currentPage = useViewerStore4((state) => state.currentPage);
@@ -24226,6 +24083,7 @@ var Viewer = ({
24226
24083
  const uiTheme = useViewerStore4((state) => state.uiTheme);
24227
24084
  const viewMode = useViewerStore4((state) => state.viewMode);
24228
24085
  const zoom = useViewerStore4((state) => state.zoom);
24086
+ const storeViewerMode = useViewerStore4((state) => state.viewerMode);
24229
24087
  const listRef = useRef4(null);
24230
24088
  const horizontalScrollRef = useRef4(null);
24231
24089
  const isDark = uiTheme === "dark";
@@ -24234,7 +24092,14 @@ var Viewer = ({
24234
24092
  const isSingle = viewMode === "single";
24235
24093
  const renderTargetType = engine.getRenderTargetType?.() ?? "canvas";
24236
24094
  const isWebView = renderTargetType === "webview";
24237
- const isDedicatedAndroidPdfViewer = Platform2.OS === "android" && !!useDedicatedAndroidPdfViewer && pageCount > 0 && !isWebView && !!getDedicatedAndroidPdfEngineId(engine);
24095
+ const resolvedViewerMode = viewerMode ?? (useDedicatedAndroidPdfViewer ? "native" : storeViewerMode);
24096
+ const nativeEngineId = getDedicatedAndroidPdfEngineId(engine);
24097
+ const isNativePdfViewer = shouldUseNativePdfViewer({
24098
+ viewerMode: resolvedViewerMode,
24099
+ pageCount,
24100
+ isWebView,
24101
+ nativeEngineId
24102
+ });
24238
24103
  const perfEnabled = isMobilePerfEnabled();
24239
24104
  const mountedAtRef = useRef4(perfNow());
24240
24105
  const readyLoggedRef = useRef4(false);
@@ -25388,7 +25253,7 @@ var Viewer = ({
25388
25253
  if (isWebView) {
25389
25254
  return /* @__PURE__ */ jsx5(View4, { style: [styles4.container, isDark && styles4.containerDark], children: /* @__PURE__ */ jsx5(WebViewViewer_default, { engine }) });
25390
25255
  }
25391
- if (isDedicatedAndroidPdfViewer) {
25256
+ if (isNativePdfViewer) {
25392
25257
  return /* @__PURE__ */ jsx5(View4, { style: [styles4.container, isDark && styles4.containerDark], children: /* @__PURE__ */ jsx5(DedicatedAndroidPdfViewer, { engine }) });
25393
25258
  }
25394
25259
  if (isSingle) {
@@ -28511,7 +28376,7 @@ var styles10 = StyleSheet10.create({
28511
28376
  var BottomBar_default = BottomBar;
28512
28377
 
28513
28378
  // components/SettingsSheet.tsx
28514
- import { useCallback as useCallback5, useEffect as useEffect9, useMemo as useMemo6, useState as useState9 } from "react";
28379
+ import { useCallback as useCallback5, useMemo as useMemo6 } from "react";
28515
28380
  import { Dimensions as Dimensions2, View as View11, Text as Text6, Pressable as Pressable9, StyleSheet as StyleSheet11 } from "react-native";
28516
28381
  import BottomSheet2, {
28517
28382
  BottomSheetBackdrop as BottomSheetBackdrop2,
@@ -28562,14 +28427,10 @@ var SettingsSheet = ({
28562
28427
  const isPaged = viewMode === "single";
28563
28428
  const isDouble = viewMode === "double";
28564
28429
  const t = getStrings(locale);
28565
- const [hasBeenVisible, setHasBeenVisible] = useState9(visible);
28566
28430
  const snapPoints = useMemo6(
28567
28431
  () => [Math.min(640, Dimensions2.get("window").height * 0.72)],
28568
28432
  []
28569
28433
  );
28570
- useEffect9(() => {
28571
- if (visible) setHasBeenVisible(true);
28572
- }, [visible]);
28573
28434
  const renderBackdrop = useCallback5(
28574
28435
  (props) => /* @__PURE__ */ jsx12(
28575
28436
  BottomSheetBackdrop2,
@@ -28608,7 +28469,6 @@ var SettingsSheet = ({
28608
28469
  engine.setZoom(next);
28609
28470
  setDocumentState({ zoom: next });
28610
28471
  };
28611
- if (!hasBeenVisible) return null;
28612
28472
  return /* @__PURE__ */ jsx12(View11, { style: styles11.modalRoot, pointerEvents: "box-none", children: /* @__PURE__ */ jsx12(
28613
28473
  BottomSheet2,
28614
28474
  {
@@ -29131,7 +28991,7 @@ var styles11 = StyleSheet11.create({
29131
28991
  var SettingsSheet_default = SettingsSheet;
29132
28992
 
29133
28993
  // components/CoverPreview.tsx
29134
- import { useEffect as useEffect10, useMemo as useMemo7, useRef as useRef7, useState as useState10 } from "react";
28994
+ import { useEffect as useEffect9, useMemo as useMemo7, useRef as useRef7, useState as useState9 } from "react";
29135
28995
  import {
29136
28996
  ActivityIndicator,
29137
28997
  StyleSheet as StyleSheet12,
@@ -29189,18 +29049,18 @@ var CoverPreview = ({
29189
29049
  onLoadEnd,
29190
29050
  onError
29191
29051
  }) => {
29192
- const [engine, setEngine] = useState10(null);
29193
- const [layoutReady, setLayoutReady] = useState10(false);
29194
- const [loaded, setLoaded] = useState10(false);
29195
- const [loading, setLoading] = useState10(false);
29196
- const [error, setError] = useState10(null);
29052
+ const [engine, setEngine] = useState9(null);
29053
+ const [layoutReady, setLayoutReady] = useState9(false);
29054
+ const [loaded, setLoaded] = useState9(false);
29055
+ const [loading, setLoading] = useState9(false);
29056
+ const [error, setError] = useState9(null);
29197
29057
  const viewRef = useRef7(null);
29198
29058
  const resolvedType = useMemo7(() => inferDocumentType(source, type), [source, type]);
29199
29059
  const isPdf = resolvedType === "pdf";
29200
29060
  const hasNativePageView = Boolean(UIManager2.getViewManagerConfig?.("PapyrusPageView"));
29201
29061
  const canRender = !isPdf || hasNativePageView;
29202
29062
  const shouldRender = Boolean(visible);
29203
- useEffect10(() => {
29063
+ useEffect9(() => {
29204
29064
  if (!shouldRender) {
29205
29065
  if (!keepAlive) {
29206
29066
  setEngine(null);
@@ -29213,7 +29073,7 @@ var CoverPreview = ({
29213
29073
  setEngine(new MobileDocumentEngine());
29214
29074
  }
29215
29075
  }, [shouldRender, keepAlive, engine, canRender]);
29216
- useEffect10(() => {
29076
+ useEffect9(() => {
29217
29077
  if (!engine || !shouldRender || !canRender) return;
29218
29078
  let active = true;
29219
29079
  setLoading(true);
@@ -29240,13 +29100,13 @@ var CoverPreview = ({
29240
29100
  active = false;
29241
29101
  };
29242
29102
  }, [engine, shouldRender, canRender, source, type, pageIndex, isPdf, onLoadStart, onLoadEnd, onError]);
29243
- useEffect10(() => {
29103
+ useEffect9(() => {
29244
29104
  if (!engine || !isPdf || !loaded || !layoutReady || !shouldRender || !canRender) return;
29245
29105
  const viewTag = findNodeHandle3(viewRef.current);
29246
29106
  if (!viewTag) return;
29247
29107
  engine.renderPage(pageIndex, viewTag, renderScale);
29248
29108
  }, [engine, isPdf, loaded, layoutReady, shouldRender, canRender, pageIndex, renderScale]);
29249
- useEffect10(() => {
29109
+ useEffect9(() => {
29250
29110
  return () => {
29251
29111
  engine?.destroy();
29252
29112
  };
@@ -29313,7 +29173,7 @@ var styles12 = StyleSheet12.create({
29313
29173
  var CoverPreview_default = CoverPreview;
29314
29174
 
29315
29175
  // components/ReadingShell.tsx
29316
- import React14, { useState as useState12 } from "react";
29176
+ import React14, { useState as useState11 } from "react";
29317
29177
  import { Keyboard as Keyboard2, View as View19, StyleSheet as StyleSheet19 } from "react-native";
29318
29178
  import { useViewerStore as useViewerStore17 } from "@papyrus-sdk/core";
29319
29179
 
@@ -29938,7 +29798,7 @@ var styles16 = StyleSheet16.create({
29938
29798
  });
29939
29799
 
29940
29800
  // components/SearchOverlay.tsx
29941
- import { useEffect as useEffect11, useMemo as useMemo9, useState as useState11 } from "react";
29801
+ import { useEffect as useEffect10, useMemo as useMemo9, useState as useState10 } from "react";
29942
29802
  import {
29943
29803
  Keyboard,
29944
29804
  Pressable as Pressable14,
@@ -29967,14 +29827,14 @@ function SearchOverlay({
29967
29827
  uiTheme,
29968
29828
  accentColor
29969
29829
  } = useViewerStore15();
29970
- const [draft, setDraft] = useState11(searchQuery);
29971
- const [isSearching, setIsSearching] = useState11(false);
29830
+ const [draft, setDraft] = useState10(searchQuery);
29831
+ const [isSearching, setIsSearching] = useState10(false);
29972
29832
  const isDark = uiTheme === "dark";
29973
29833
  const t = getStrings(locale);
29974
29834
  const searchService = useMemo9(() => new SearchService(engine), [engine]);
29975
29835
  const currentCount = searchResults.length > 0 && activeSearchIndex >= 0 ? activeSearchIndex + 1 : 0;
29976
29836
  const targetLabel = documentType === "pdf" ? t.page : documentType === "epub" ? t.contents : t.progress;
29977
- useEffect11(() => {
29837
+ useEffect10(() => {
29978
29838
  if (!visible) return;
29979
29839
  setDraft(searchQuery);
29980
29840
  }, [searchQuery, visible]);
@@ -30459,12 +30319,12 @@ function ReadingShell({
30459
30319
  uiTheme,
30460
30320
  accentColor
30461
30321
  } = useViewerStore17();
30462
- const [overflowOpen, setOverflowOpen] = useState12(false);
30463
- const [infoOpen, setInfoOpen] = useState12(false);
30464
- const [actionsOpen, setActionsOpen] = useState12(false);
30465
- const [settingsOpen, setSettingsOpen] = useState12(false);
30466
- const [searchResultsOpen, setSearchResultsOpen] = useState12(false);
30467
- const [pageJumpOpen, setPageJumpOpen] = useState12(false);
30322
+ const [overflowOpen, setOverflowOpen] = useState11(false);
30323
+ const [infoOpen, setInfoOpen] = useState11(false);
30324
+ const [actionsOpen, setActionsOpen] = useState11(false);
30325
+ const [settingsOpen, setSettingsOpen] = useState11(false);
30326
+ const [searchResultsOpen, setSearchResultsOpen] = useState11(false);
30327
+ const [pageJumpOpen, setPageJumpOpen] = useState11(false);
30468
30328
  const isDark = uiTheme === "dark";
30469
30329
  React14.useEffect(() => {
30470
30330
  const showSubscription = Keyboard2.addListener("keyboardDidShow", () => {
@@ -30668,6 +30528,7 @@ export {
30668
30528
  DocumentActionsSheet,
30669
30529
  InfoSheet,
30670
30530
  MOBILE_CHROME_METRICS,
30531
+ DedicatedAndroidPdfViewer as NativePdfDocumentViewer,
30671
30532
  OverflowSheet,
30672
30533
  PageRenderer_default as PageRenderer,
30673
30534
  ProgressPill,