react-native-optimized-pdf 1.1.0 → 1.3.1

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/CHANGELOG.md CHANGED
@@ -5,31 +5,48 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## [Unreleased]
8
+ ## [1.3.1] - 2026-11-01
9
+
10
+ ### Fixed
11
+
12
+ - Local `file://` URIs and absolute paths are returned directly instead of being passed to the HTTP downloader, fixing local PDF opening on Android.
13
+
14
+ ### Changed
15
+
16
+ - Replaced the abandoned `react-native-fs` with the maintained `@dr.pogodin/react-native-fs` (`^2.41.0`).
17
+
18
+ ## [1.3.0] - 2026-08-08
9
19
 
10
20
  ### Added
11
21
 
12
- - Modular architecture with separated concerns
13
- - `PdfCacheService` for advanced cache management
14
- - `PdfNavigationControls` as standalone component
15
- - `PdfLoadingOverlay` and `PdfErrorOverlay` components
16
- - `showNavigationControls` prop to hide/show built-in controls
17
- - `onPageChange` callback for page change events
18
- - Comprehensive TypeScript types in `/src/types`
19
- - JSDoc comments for better IDE support
20
- - Cache utility methods (clearCache, clearAllCache, getCacheSize)
21
- - Accessibility labels for navigation controls
22
+ - Annotation (annots) rendering support on Android and iOS
23
+ - Tile-based PDF rendering for high-quality zoom (Android)
24
+ - 100% automated test coverage for the TypeScript/JavaScript surface with a hard gate
25
+ - CI workflow (GitHub Actions) running lint, typecheck, and coverage-gated tests on every push/PR
26
+ - Test infrastructure: Jest, React Native Testing Library, and coverage thresholds in `jest.config.js`
27
+ - Unit suites for `PdfCacheService`, `PdfNavigationControls`, `PdfOverlays`, and constants
28
+ - Integration suite for `OptimizedPdfView` covering the load state machine, events, navigation, source changes, and platform fallback
22
29
 
23
30
  ### Changed
24
31
 
25
- - Refactored component structure for better maintainability
26
- - Improved error handling and messaging
27
- - Better TypeScript type exports
28
- - Enhanced documentation with more examples
29
- - Cleaner imports using ES6 modules consistently
32
+ - Android: migrated to `pdfiumandroid` and replaced previous rendering pipeline with tiled rendering
33
+ - iOS: introduced annotation flattening using PDFKit when needed, while keeping CGPDF rendering for performance
34
+ - Updated dependencies and improved TypeScript configuration
35
+ - Removed unused and dead iOS code (delegate protocol, view/manager methods, error cases, imports)
36
+ - Reconciled `PDF`/`Pdf` naming across the iOS Swift class, `@objc` export, Objective-C manager, and JS registration
37
+ - Extracted duplicated `file://` URL handling into a shared iOS helper
38
+ - Removed the unused `PdfSource.method` field (documented as non-breaking: the field was never consumed)
39
+ - Removed unused `ERROR_MESSAGES.LOAD_FAILED` and `INVALID_SOURCE` entries
40
+ - Aligned the iOS `maximumZoom` default with the JS side
41
+
42
+ ### Improved
43
+
44
+ - Better zoom quality and rendering performance
45
+ - More efficient memory usage across large documents
46
+ - Minor UI and typing improvements
30
47
 
31
48
  ### Fixed
32
49
 
33
- - Memory leaks in useEffect cleanup
34
- - Proper file:// protocol handling
35
- - Cache validation logic
50
+ - Annotations not being rendered
51
+ - `_cancelled` reset semantics in `TiledPDFPageView`
52
+ - Duplicated imports across iOS sources
@@ -0,0 +1,128 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity
10
+ and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ - Demonstrating empathy and kindness toward other people
21
+ - Being respectful of differing opinions, viewpoints, and experiences
22
+ - Giving and gracefully accepting constructive feedback
23
+ - Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ - Focusing on what is best not just for us as individuals, but for the
26
+ overall community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ - The use of sexualized language or imagery, and sexual attention or
31
+ advances of any kind
32
+ - Trolling, insulting or derogatory comments, and personal or political attacks
33
+ - Public or private harassment
34
+ - Publishing others' private information, such as a physical or email
35
+ address, without their explicit permission
36
+ - Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ .
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series
86
+ of actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or
93
+ permanent ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within
113
+ the community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.0, available at
119
+ https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120
+
121
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct
122
+ enforcement ladder](https://github.com/mozilla/diversity).
123
+
124
+ [homepage]: https://www.contributor-covenant.org
125
+
126
+ For answers to common questions about this code of conduct, see the FAQ at
127
+ https://www.contributor-covenant.org/faq. Translations are available at
128
+ https://www.contributor-covenant.org/translations.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Herbeth Lucas de Sousa Pereira
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,20 +1,27 @@
1
1
  # React Native Optimized PDF
2
2
 
3
- High-performance PDF viewer for React Native with optimized memory usage. Uses CATiledLayer on iOS and PdfRenderer on Android for smooth rendering with automatic caching.
3
+ High-performance **React Native PDF viewer** for iOS and Android.
4
+
5
+ - 🚀 Handles large PDFs (1000+ pages) without crashes
6
+ - 🔍 Smooth zoom with tile-based rendering
7
+ - ✍️ Supports annotations (annots)
8
+ - 🧠 Memory-efficient and optimized for performance
9
+
10
+ If you're looking for a **React Native PDF viewer** that supports large files, zoom, and annotations, this library provides a fast and reliable solution.
4
11
 
5
12
  ## Features
6
13
 
7
- - 🚀 **Optimized memory usage** with CATiledLayer (iOS) and PdfRenderer (Android)
8
- - 📦 **Automatic caching** with configurable expiration
9
- - 📱 **Smooth zoom and scroll** with customizable maximum zoom
10
- - 🎯 **Built-in page navigation** with optional custom controls
11
- - 📊 **Comprehensive event callbacks** for load, error, and page events
12
- - 🎨 **High-quality rendering** with antialiasing support
13
- - 📈 **Download progress tracking** for remote PDFs
14
- - ⚡ **TypeScript support** with full type definitions
15
- - 🔧 **Modular architecture** with exportable utilities
16
- - 🤖 **Cross-platform** support for iOS and Android
17
- - 🔒 **Password-protected PDF** support
14
+ - 🚀 Optimized memory usage with CATiledLayer (iOS) and PdfRenderer/Pdfium (Android)
15
+ - ✍️ Annotation (annots) rendering support
16
+ - 📦 Automatic caching with configurable expiration
17
+ - 📱 Smooth zoom and scroll with tiled rendering
18
+ - 🎯 Built-in page navigation with optional custom controls
19
+ - 📊 Event callbacks for load, error, and page changes
20
+ - 🎨 High-quality rendering with antialiasing
21
+ - 📈 Download progress tracking
22
+ - ⚡ Full TypeScript support
23
+ - 🤖 Cross-platform (iOS & Android)
24
+ - 🔒 Password-protected PDFs
18
25
 
19
26
  ## Installation
20
27
 
@@ -34,6 +41,10 @@ cd ios && pod install
34
41
 
35
42
  No additional setup required! The module will be automatically linked.
36
43
 
44
+ ### Local files
45
+
46
+ `source.uri` accepts a remote URL (`http://` or `https://`), a `file://` URI, or an absolute path. Local files are opened directly and are not copied to the cache; only remote URLs are downloaded. Remote downloads use the maintained [`@dr.pogodin/react-native-fs`](https://github.com/birdofpreyru/react-native-fs) package, installed automatically as a dependency.
47
+
37
48
  ## Usage
38
49
 
39
50
  ### Basic Example
@@ -191,8 +202,8 @@ const isValid = await PdfCacheService.isCacheValid({
191
202
 
192
203
  | Property | Type | Default | Description |
193
204
  | --------------- | ------------------------ | ------------ | ------------------------------------------------------------ |
194
- | `uri` | `string` | **required** | PDF file URI (remote URL or local path) |
195
- | `cache` | `boolean` | `true` | Enable local caching |
205
+ | `uri` | `string` | **required** | PDF file URI (remote URL, `file://` URI, or absolute path) |
206
+ | `cache` | `boolean` | `true` | Enable local caching for remote URLs (ignored for local files) |
196
207
  | `cacheFileName` | `string` | MD5 of URI | Custom filename for cached file |
197
208
  | `expiration` | `number` | - | Cache expiration in seconds (0 or undefined = no expiration) |
198
209
  | `headers` | `Record<string, string>` | - | HTTP headers for download |
@@ -203,7 +214,7 @@ Static methods for managing PDF cache:
203
214
 
204
215
  - `getCacheFilePath(source: PdfSource): string` - Get local cache path
205
216
  - `isCacheValid(source: PdfSource): Promise<boolean>` - Check if cache is valid
206
- - `downloadPdf(source: PdfSource, onProgress?: (percent: number) => void): Promise<string>` - Download and cache PDF
217
+ - `downloadPdf(source: PdfSource, onProgress?: (percent: number) => void): Promise<string>` - Download and cache a remote PDF; local paths are returned directly
207
218
  - `clearCache(source: PdfSource): Promise<void>` - Clear specific cached file
208
219
  - `clearAllCache(): Promise<void>` - Clear all cached PDFs
209
220
  - `getCacheSize(): Promise<number>` - Get total cache size in bytes
@@ -226,26 +237,6 @@ import { PdfNavigationControls } from 'react-native-optimized-pdf';
226
237
  />;
227
238
  ```
228
239
 
229
- ### PdfLoadingOverlay
230
-
231
- Loading state component with progress:
232
-
233
- ```tsx
234
- import { PdfLoadingOverlay } from 'react-native-optimized-pdf';
235
-
236
- <PdfLoadingOverlay progress={75} />;
237
- ```
238
-
239
- ### PdfErrorOverlay
240
-
241
- Error state component:
242
-
243
- ```tsx
244
- import { PdfErrorOverlay } from 'react-native-optimized-pdf';
245
-
246
- <PdfErrorOverlay error="Failed to load PDF" />;
247
- ```
248
-
249
240
  ## Platform Support
250
241
 
251
242
  | Platform | Supported | Min Version |
@@ -289,6 +280,26 @@ import { PdfErrorOverlay } from 'react-native-optimized-pdf';
289
280
  - Pass the password via the `password` prop
290
281
  - Check for "Invalid password" in error message to show retry prompt
291
282
 
283
+ ## Development
284
+
285
+ ### Commands
286
+
287
+ ```bash
288
+ # Run the test suite
289
+ yarn test
290
+
291
+ # Run tests with coverage (enforces the 100% gate)
292
+ yarn test:coverage
293
+
294
+ # Lint the codebase
295
+ yarn lint
296
+
297
+ # Type-check the codebase
298
+ yarn typecheck
299
+ ```
300
+
301
+ The test suite enforces **100% coverage** (lines, statements, functions, and branches) on the TypeScript/JavaScript surface (`src/**` and `index.ts`). `yarn test:coverage` exits non-zero if any threshold drops below 100%. The thresholds live in `jest.config.js`, and CI (GitHub Actions) runs `yarn lint`, `yarn typecheck`, and `yarn test:coverage` on every push and pull request, blocking merges when the gate fails.
302
+
292
303
  ## License
293
304
 
294
305
  MIT
@@ -300,3 +311,7 @@ Contributions are welcome! Please open an issue or submit a pull request.
300
311
  ## Author
301
312
 
302
313
  Created with ❤️ for the React Native community
314
+
315
+ ## Keywords
316
+
317
+ React Native PDF viewer, PDF reader, large PDF, PDF annotations, PDF rendering, iOS PDF, Android PDF, fast PDF viewer
package/SECURITY.md ADDED
@@ -0,0 +1,21 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ Use this section to tell people about which versions of your project are
6
+ currently being supported with security updates.
7
+
8
+ | Version | Supported |
9
+ | ------- | ------------------ |
10
+ | 5.1.x | :white_check_mark: |
11
+ | 5.0.x | :x: |
12
+ | 4.0.x | :white_check_mark: |
13
+ | < 4.0 | :x: |
14
+
15
+ ## Reporting a Vulnerability
16
+
17
+ Use this section to tell people how to report a vulnerability.
18
+
19
+ Tell them where to go, how often they can expect to get an update on a
20
+ reported vulnerability, what to expect if the vulnerability is accepted or
21
+ declined, etc.
@@ -53,5 +53,5 @@ repositories {
53
53
  dependencies {
54
54
  implementation "org.jetbrains.kotlin:kotlin-stdlib:${safeExtGet('kotlinVersion', '1.9.0')}"
55
55
  implementation "com.facebook.react:react-android:+"
56
- implementation "com.tom-roush:pdfbox-android:2.0.27.0"
56
+ implementation "io.legere:pdfiumandroid:1.0.32"
57
57
  }