react-native-pdf-jsi 1.0.2 → 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.
@@ -291,6 +291,54 @@ export const usePDFJSI = (options = {}) => {
291
291
  return Array.from(pdfInstancesRef.current.values());
292
292
  }, []);
293
293
 
294
+ /**
295
+ * Lazy load pages for large PDF files
296
+ */
297
+ const lazyLoadPages = useCallback(async (pdfId, currentPage, preloadRadius = 3, totalPages = null) => {
298
+ try {
299
+ if (isJSIAvailable) {
300
+ return await PDFJSI.lazyLoadPages(pdfId, currentPage, preloadRadius, totalPages);
301
+ } else {
302
+ throw new Error('JSI not available');
303
+ }
304
+ } catch (error) {
305
+ console.error('📱 usePDFJSI: Error lazy loading pages:', error);
306
+ throw error;
307
+ }
308
+ }, [isJSIAvailable]);
309
+
310
+ /**
311
+ * Progressive loading for large PDF files
312
+ */
313
+ const progressiveLoadPages = useCallback(async (pdfId, startPage = 1, batchSize = 5, onProgress = null) => {
314
+ try {
315
+ if (isJSIAvailable) {
316
+ return await PDFJSI.progressiveLoadPages(pdfId, startPage, batchSize, onProgress);
317
+ } else {
318
+ throw new Error('JSI not available');
319
+ }
320
+ } catch (error) {
321
+ console.error('📱 usePDFJSI: Error progressive loading pages:', error);
322
+ throw error;
323
+ }
324
+ }, [isJSIAvailable]);
325
+
326
+ /**
327
+ * Smart caching for frequently accessed pages
328
+ */
329
+ const smartCacheFrequentPages = useCallback(async (pdfId, frequentPages = []) => {
330
+ try {
331
+ if (isJSIAvailable) {
332
+ return await PDFJSI.smartCacheFrequentPages(pdfId, frequentPages);
333
+ } else {
334
+ throw new Error('JSI not available');
335
+ }
336
+ } catch (error) {
337
+ console.error('📱 usePDFJSI: Error smart caching pages:', error);
338
+ throw error;
339
+ }
340
+ }, [isJSIAvailable]);
341
+
294
342
  // Initialize JSI on mount if autoInitialize is enabled
295
343
  useEffect(() => {
296
344
  if (autoInitialize && !isInitialized) {
@@ -338,6 +386,11 @@ export const usePDFJSI = (options = {}) => {
338
386
  removePDFInstance,
339
387
  getPDFInstances,
340
388
 
389
+ // Lazy loading and advanced features
390
+ lazyLoadPages,
391
+ progressiveLoadPages,
392
+ smartCacheFrequentPages,
393
+
341
394
  // Utilities
342
395
  initializeJSI
343
396
  };