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

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 CHANGED
@@ -34,6 +34,56 @@ await engine.load({ type: 'pdf', source: { uri: 'https://example.com/book.pdf' }
34
34
  />
35
35
  ```
36
36
 
37
+ ## Topbar Customization
38
+
39
+ `Topbar` supports replacing the default "Papyrus" text and logo.
40
+
41
+ ```tsx
42
+ <Topbar
43
+ engine={engine}
44
+ title="My Reader"
45
+ logo={<MyLogoIcon />}
46
+ onLogoPress={() => navigation.goBack()}
47
+ onOpenSettings={() => setSettingsOpen(true)}
48
+ />
49
+ ```
50
+
51
+ - `title`: replaces the default brand text.
52
+ - `logo`: custom logo node (can be icon, image, or even a `Pressable`).
53
+ - `onLogoPress`: optional callback to make the logo area act like a button.
54
+
55
+ ## Mobile Tuning Flags
56
+
57
+ Performance tuning props are available on `Viewer` and `RightSheet`:
58
+
59
+ ```tsx
60
+ <Viewer
61
+ engine={engine}
62
+ virtualWindowSize={8}
63
+ maxToRenderPerBatch={6}
64
+ removeClippedSubviews
65
+ />
66
+
67
+ <RightSheet engine={engine} thumbsInitialCount={4} />
68
+ ```
69
+
70
+ - `virtualWindowSize` (`Viewer`): FlatList window size. Default: `8`.
71
+ - `maxToRenderPerBatch` (`Viewer`): max items per render batch. Default: `6`.
72
+ - `removeClippedSubviews` (`Viewer`): detach offscreen rows. Default: `true`.
73
+ - `thumbsInitialCount` (`RightSheet`): initial thumbnails rendered when opening pages tab. Default: `4`.
74
+
75
+ Recommended starting points:
76
+
77
+ - Mid-range Android + large docs (500+ pages): `virtualWindowSize={6}`, `maxToRenderPerBatch={4}`, `thumbsInitialCount={3}`.
78
+ - High-end devices: keep defaults (`8`, `6`, `4`) and tune only if you observe jank or memory pressure.
79
+
80
+ ## Performance Tips (Mobile)
81
+
82
+ - Keep `Viewer` mounted before calling `engine.load(...)` for EPUB/TXT, so the WebView runtime is already ready.
83
+ - Prefer URI loads (`{ uri }`) for local files instead of pre-converting content to base64.
84
+ - For long documents, reduce `virtualWindowSize` and `maxToRenderPerBatch` first; then tune thumbnail pre-render count.
85
+ - On Android mid-tier devices (around 4 GB RAM), expect temporary memory spikes while parsing EPUB archives and generating first render.
86
+
37
87
  ## Mobile Performance Baseline (Audit Step)
38
88
 
39
89
  Enable runtime diagnostics before rendering the viewer:
@@ -59,3 +109,15 @@ Recommended baseline run:
59
109
  3. Scroll quickly for 10-15 seconds and capture `scroll.*` logs.
60
110
  4. Open thumbnails and capture `memory.thumbnails.*`.
61
111
  5. Jump between distant pages and check for `setDocumentState.burst`.
112
+
113
+ ## Large Files (EPUB/PDF) Troubleshooting
114
+
115
+ If large files fail to load or crash on mobile:
116
+
117
+ - Avoid RN bridge base64 conversion for large local files (OOM risk). Use `{ uri: 'file:///...' }`.
118
+ - EPUB on mobile WebView now fetches local URI content inside the runtime and opens from `ArrayBuffer`.
119
+ - If you see timeout errors:
120
+ - WebView engine request timeout for `load`: `180000ms`
121
+ - Runtime EPUB open/ready timeout: `180000ms`
122
+ - Runtime EPUB display timeout: `30000ms`
123
+ - For very large EPUBs, first-open can take longer on mid-tier Android. This is expected due to zip parsing and spine bootstrapping.
package/dist/index.d.mts CHANGED
@@ -5,6 +5,9 @@ import { StyleProp, ViewStyle } from 'react-native';
5
5
 
6
6
  interface ViewerProps {
7
7
  engine: DocumentEngine;
8
+ virtualWindowSize?: number;
9
+ maxToRenderPerBatch?: number;
10
+ removeClippedSubviews?: boolean;
8
11
  }
9
12
  declare const Viewer: React.FC<ViewerProps>;
10
13
 
@@ -18,11 +21,15 @@ interface PageRendererProps {
18
21
  horizontalPadding?: number;
19
22
  spacing?: number;
20
23
  }
21
- declare const PageRenderer: React.FC<PageRendererProps>;
24
+ declare const _default: React.NamedExoticComponent<PageRendererProps>;
22
25
 
23
26
  interface TopbarProps {
24
27
  engine: DocumentEngine;
25
28
  onOpenSettings?: () => void;
29
+ title?: string;
30
+ logo?: React.ReactNode;
31
+ onLogoPress?: () => void;
32
+ logoAccessibilityLabel?: string;
26
33
  }
27
34
  declare const Topbar: React.FC<TopbarProps>;
28
35
 
@@ -30,6 +37,7 @@ declare const ToolDock: React.FC;
30
37
 
31
38
  interface RightSheetProps {
32
39
  engine: DocumentEngine;
40
+ thumbsInitialCount?: number;
33
41
  }
34
42
  declare const RightSheet: React.FC<RightSheetProps>;
35
43
 
@@ -62,4 +70,4 @@ type CoverPreviewProps = {
62
70
  };
63
71
  declare const CoverPreview: React.FC<CoverPreviewProps>;
64
72
 
65
- export { AnnotationEditor, BottomBar, CoverPreview, PageRenderer, RightSheet, SettingsSheet, ToolDock, Topbar, Viewer };
73
+ export { AnnotationEditor, BottomBar, CoverPreview, _default as PageRenderer, RightSheet, SettingsSheet, ToolDock, Topbar, Viewer };
package/dist/index.d.ts CHANGED
@@ -5,6 +5,9 @@ import { StyleProp, ViewStyle } from 'react-native';
5
5
 
6
6
  interface ViewerProps {
7
7
  engine: DocumentEngine;
8
+ virtualWindowSize?: number;
9
+ maxToRenderPerBatch?: number;
10
+ removeClippedSubviews?: boolean;
8
11
  }
9
12
  declare const Viewer: React.FC<ViewerProps>;
10
13
 
@@ -18,11 +21,15 @@ interface PageRendererProps {
18
21
  horizontalPadding?: number;
19
22
  spacing?: number;
20
23
  }
21
- declare const PageRenderer: React.FC<PageRendererProps>;
24
+ declare const _default: React.NamedExoticComponent<PageRendererProps>;
22
25
 
23
26
  interface TopbarProps {
24
27
  engine: DocumentEngine;
25
28
  onOpenSettings?: () => void;
29
+ title?: string;
30
+ logo?: React.ReactNode;
31
+ onLogoPress?: () => void;
32
+ logoAccessibilityLabel?: string;
26
33
  }
27
34
  declare const Topbar: React.FC<TopbarProps>;
28
35
 
@@ -30,6 +37,7 @@ declare const ToolDock: React.FC;
30
37
 
31
38
  interface RightSheetProps {
32
39
  engine: DocumentEngine;
40
+ thumbsInitialCount?: number;
33
41
  }
34
42
  declare const RightSheet: React.FC<RightSheetProps>;
35
43
 
@@ -62,4 +70,4 @@ type CoverPreviewProps = {
62
70
  };
63
71
  declare const CoverPreview: React.FC<CoverPreviewProps>;
64
72
 
65
- export { AnnotationEditor, BottomBar, CoverPreview, PageRenderer, RightSheet, SettingsSheet, ToolDock, Topbar, Viewer };
73
+ export { AnnotationEditor, BottomBar, CoverPreview, _default as PageRenderer, RightSheet, SettingsSheet, ToolDock, Topbar, Viewer };