react-native-pdf-jsi 1.0.3 → 2.0.0
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 +121 -4
- package/android/src/main/java/org/wonday/pdf/PDFNativeCacheManager.java +748 -0
- package/ios/RNPDFPdf/PDFJSIManager.h +15 -0
- package/ios/RNPDFPdf/PDFJSIManager.m +581 -0
- package/ios/RNPDFPdf/PDFNativeCacheManager.h +20 -0
- package/ios/RNPDFPdf/PDFNativeCacheManager.m +743 -0
- package/package.json +32 -4
- package/src/EnhancedPdfView.js +52 -2
- package/src/PDFJSI.js +247 -3
- package/src/examples/PDFJSIExample.js +463 -195
- package/src/hooks/usePDFJSI.js +53 -0
package/README.md
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
|
-
#
|
|
2
|
-
[](https://www.npmjs.com/package/react-native-pdf-jsi)
|
|
3
|
+
[](https://www.npmjs.com/package/react-native-pdf-jsi)
|
|
4
|
+
[](https://github.com/126punith/react-native-enhanced-pdf)
|
|
3
5
|
|
|
4
|
-
**
|
|
6
|
+
**The fastest React Native PDF viewer with JSI acceleration - up to 80x faster than traditional bridge!**
|
|
7
|
+
|
|
8
|
+
A high-performance React Native PDF viewer component with JSI (JavaScript Interface) integration for enhanced speed and efficiency. Perfect for large PDF files with lazy loading, smart caching, progressive loading, and zero-bridge overhead operations.
|
|
9
|
+
|
|
10
|
+
## 🎉 Version 2.0.0 - Major Release!
|
|
11
|
+
|
|
12
|
+
**We've completely rewritten the core architecture with revolutionary performance improvements!**
|
|
13
|
+
|
|
14
|
+
- **🚀 Complete JSI Integration**: Full native C++ implementation for Android and iOS
|
|
15
|
+
- **📄 Lazy Loading System**: Revolutionary approach to handling large PDF files
|
|
16
|
+
- **🎯 Smart Caching Engine**: 30-day persistent cache with intelligent management
|
|
17
|
+
- **📊 Progressive Loading**: Batch-based loading for optimal user experience
|
|
18
|
+
- **💾 Advanced Memory Management**: Intelligent memory optimization for large documents
|
|
19
|
+
|
|
20
|
+
*This is a drop-in replacement for react-native-pdf with significant performance improvements.*
|
|
5
21
|
|
|
6
22
|
## 🚀 Performance Breakthrough
|
|
7
23
|
|
|
@@ -12,6 +28,27 @@
|
|
|
12
28
|
| Cache Access | 8ms | 0.1ms | **80x faster** |
|
|
13
29
|
| Text Search | 120ms | 15ms | **8x faster** |
|
|
14
30
|
|
|
31
|
+
## 🔥 Why Choose react-native-pdf-jsi?
|
|
32
|
+
|
|
33
|
+
- **⚡ Up to 80x Faster**: Direct JavaScript-to-Native communication via JSI
|
|
34
|
+
- **📄 Lazy Loading**: Optimized loading for large PDF files with configurable preload radius
|
|
35
|
+
- **🎯 Smart Caching**: 30-day persistent cache with intelligent memory management
|
|
36
|
+
- **📱 Cross-Platform**: Full support for iOS, Android, and Windows
|
|
37
|
+
- **🔄 Progressive Loading**: Batch-based loading with configurable batch sizes
|
|
38
|
+
- **💾 Memory Optimized**: Advanced memory management for large documents
|
|
39
|
+
- **🔍 Advanced Search**: Cached text search with bounds detection
|
|
40
|
+
- **📊 Performance Metrics**: Real-time performance monitoring and analytics
|
|
41
|
+
|
|
42
|
+
## 🆚 Alternative to react-native-pdf
|
|
43
|
+
|
|
44
|
+
**react-native-pdf-jsi** is the enhanced, high-performance alternative to the standard `react-native-pdf` package. If you're experiencing slow loading times with large PDF files or need better performance, this package provides:
|
|
45
|
+
|
|
46
|
+
- **Zero Bridge Overhead**: Direct native communication via JSI
|
|
47
|
+
- **Lazy Loading Support**: Perfect for large PDF files that take too long to load
|
|
48
|
+
- **Persistent Caching**: 30-day cache with automatic cleanup
|
|
49
|
+
- **Memory Optimization**: Intelligent memory management for better performance
|
|
50
|
+
- **Drop-in Replacement**: Compatible with existing react-native-pdf code
|
|
51
|
+
|
|
15
52
|
## ✨ Features
|
|
16
53
|
|
|
17
54
|
### Core Features
|
|
@@ -30,6 +67,7 @@
|
|
|
30
67
|
* **Real-time Performance Metrics** - Monitor and optimize PDF operations
|
|
31
68
|
* **Graceful Fallback** - Seamless bridge mode when JSI unavailable
|
|
32
69
|
* **Progressive Loading** - Smart preloading with background queue processing
|
|
70
|
+
* **Lazy Loading** - Optimized loading for large PDF files with configurable preload radius
|
|
33
71
|
* **Advanced Search** - Cached text search with bounds detection
|
|
34
72
|
* **React Hooks** - Easy integration with `usePDFJSI` hook
|
|
35
73
|
* **Enhanced Components** - Drop-in replacement with automatic JSI detection
|
|
@@ -436,7 +474,21 @@ if (stats.jsiEnabled) {
|
|
|
436
474
|
|
|
437
475
|
## 📝 Changelog
|
|
438
476
|
|
|
439
|
-
###
|
|
477
|
+
### v2.0.0 (2025) - Latest 🚀 MAJOR RELEASE
|
|
478
|
+
- 🎉 **Major Version Release**: Significant performance improvements and new features
|
|
479
|
+
- 🚀 **Complete JSI Integration**: Full Android and iOS JSI implementation with native C++ optimizations
|
|
480
|
+
- 📄 **Lazy Loading System**: Revolutionary lazy loading for large PDF files with configurable preload radius
|
|
481
|
+
- 🎯 **Smart Caching Engine**: 30-day persistent cache with LRU eviction and background cleanup
|
|
482
|
+
- 📊 **Progressive Loading**: Batch-based progressive loading with configurable batch sizes
|
|
483
|
+
- 💾 **Advanced Memory Management**: Intelligent memory optimization for large documents
|
|
484
|
+
- 🔍 **Enhanced Search**: Cached text search with bounds detection and performance tracking
|
|
485
|
+
- 📱 **Native Cache Managers**: Complete Android and iOS native cache implementations
|
|
486
|
+
- 🔧 **Performance Monitoring**: Real-time performance metrics and analytics
|
|
487
|
+
- 📚 **Comprehensive Examples**: Updated examples with lazy loading and advanced features
|
|
488
|
+
- 🏷️ **SEO Optimization**: Enhanced discoverability with 40+ keywords and better descriptions
|
|
489
|
+
- 📈 **Better Documentation**: Improved README with performance comparisons and usage examples
|
|
490
|
+
|
|
491
|
+
### v1.0.3 (2025)
|
|
440
492
|
- 🔗 **GitHub URL Fix**: Corrected repository URLs to point to the actual GitHub repository
|
|
441
493
|
- 📚 **Documentation Fix**: Updated README with correct package name and installation instructions
|
|
442
494
|
- 🔧 **Package Clarity**: Clear distinction between npm package name (`react-native-pdf-jsi`) and import names (`react-native-pdf-enhanced`)
|
|
@@ -533,6 +585,71 @@ await EnhancedPdfUtils.clearAllCaches();
|
|
|
533
585
|
await EnhancedPdfUtils.optimizeAllMemory();
|
|
534
586
|
```
|
|
535
587
|
|
|
588
|
+
### Lazy Loading for Large PDF Files
|
|
589
|
+
|
|
590
|
+
```jsx
|
|
591
|
+
import React, { useRef, useEffect } from 'react';
|
|
592
|
+
import { View } from 'react-native';
|
|
593
|
+
import Pdf from 'react-native-pdf-enhanced';
|
|
594
|
+
|
|
595
|
+
export default function LazyLoadingExample() {
|
|
596
|
+
const pdfRef = useRef(null);
|
|
597
|
+
|
|
598
|
+
const handlePageChange = async (page) => {
|
|
599
|
+
if (pdfRef.current) {
|
|
600
|
+
try {
|
|
601
|
+
// Lazy load pages around current page
|
|
602
|
+
const result = await pdfRef.current.lazyLoadPages(page, 3, 100);
|
|
603
|
+
console.log('🚀 Lazy loaded pages:', result.preloadedRange);
|
|
604
|
+
|
|
605
|
+
// Progressive loading for large PDFs
|
|
606
|
+
const progressiveResult = await pdfRef.current.progressiveLoadPages(
|
|
607
|
+
1, // start page
|
|
608
|
+
5, // batch size
|
|
609
|
+
(progress) => {
|
|
610
|
+
console.log(`📄 Loaded batch ${progress.batchStartPage}-${progress.batchEndPage}`);
|
|
611
|
+
}
|
|
612
|
+
);
|
|
613
|
+
|
|
614
|
+
console.log('📊 Progressive loading completed:', progressiveResult.totalLoaded, 'pages');
|
|
615
|
+
|
|
616
|
+
} catch (error) {
|
|
617
|
+
console.error('❌ Lazy loading error:', error);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
const handleSmartCache = async () => {
|
|
623
|
+
if (pdfRef.current) {
|
|
624
|
+
try {
|
|
625
|
+
// Cache frequently accessed pages
|
|
626
|
+
const frequentPages = [1, 2, 10, 50, 100]; // Example pages
|
|
627
|
+
const result = await pdfRef.current.smartCacheFrequentPages(frequentPages);
|
|
628
|
+
console.log('🎯 Smart cached pages:', result.successfulCaches);
|
|
629
|
+
} catch (error) {
|
|
630
|
+
console.error('❌ Smart cache error:', error);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
|
|
635
|
+
return (
|
|
636
|
+
<View style={{ flex: 1 }}>
|
|
637
|
+
<Pdf
|
|
638
|
+
ref={pdfRef}
|
|
639
|
+
source={{ uri: 'http://example.com/large-document.pdf' }}
|
|
640
|
+
onPageChanged={handlePageChange}
|
|
641
|
+
onLoadComplete={(numberOfPages) => {
|
|
642
|
+
console.log(`📄 PDF loaded: ${numberOfPages} pages`);
|
|
643
|
+
// Initialize smart caching after load
|
|
644
|
+
handleSmartCache();
|
|
645
|
+
}}
|
|
646
|
+
style={{ flex: 1 }}
|
|
647
|
+
/>
|
|
648
|
+
</View>
|
|
649
|
+
);
|
|
650
|
+
}
|
|
651
|
+
```
|
|
652
|
+
|
|
536
653
|
## 📊 Performance Characteristics
|
|
537
654
|
|
|
538
655
|
### Memory Usage
|